grace/dots
dotfiles/nix configs
git clone https://git.gae.moe/grace/dots
ddf0c79
vulcan
1-- 2-- nvim init script by grace 3-- 4 5-- Get hostname 6local handle =io . popen ( "hostname" ) 7local hostname =handle : read ( "*a" ) or "" 8handle : close () 9hostname =hostname : gsub ( "%s+" , "" ) 10vim . g . hostname =hostname 11if string . match ( hostname , "cs.purdue.edu" ) then 12vim . g . is_purdue =true 13else 14vim . g . is_purdue =false 15end 16 17-- add required things to path 18if vim . g . is_purdue then 19vim . env . PATH =vim . env . PATH .. ':' .. os . getenv ( "HOME" ) .. '/clangd/bin:/u/riker/u98/cs240/bin' 20end 21 22require ( "plugins" ) 23require ( "native-lsp" ) 24require ( "diagnostics" ) 25require ( "remap" ) 26 27 28if vim . g . is_purdue then 29require ( "westwood-lint" ) 30end 31 32require ( "standard-lint" ) 33 34vim . cmd ( "source ~/.vim/settings.vim" ) 35 36vim . api . nvim_create_autocmd ( "BufWritePre" , { 37pattern ="*" , 38callback =function () 39local save =vim . fn . winsaveview () 40vim . cmd ( [[%s/\s\+$//e]] ) 41vim . fn . winrestview ( save ) 42end , 43} ) 44 45 46-- File IO can be slow and this might help idk 47if vim . g . is_purdue then 48vim . cmd ( "set noundofile" ) -- i forgor how to do this in lua so i didnt 49end 50 51-- 52-- vim.opt.spell = true 53-- vim.opt.spelllang = "en_us" 54-- 55 56vim . api . nvim_create_autocmd ( "FileType" , { 57pattern ="markdown" , 58callback =function () 59vim . opt_local . textwidth =80 60vim . opt_local . formatoptions ="atcqjnl" 61vim . opt_local . wrap =true 62vim . opt_local . linebreak =true 63 64-- Show column guide 65vim . opt_local . colorcolumn ="80" 66end , 67} ) 68 69-- Typst configuration 70vim . api . nvim_create_autocmd ( "FileType" , { 71pattern ="typst" , 72callback =function () 73-- Line wrapping settings 74vim . opt_local . textwidth =80 75vim . opt_local . formatoptions ="tcqjnl" 76vim . opt_local . wrap =true 77vim . opt_local . linebreak =true 78-- Show column guide 79vim . opt_local . colorcolumn ="80" 80 81-- Toggle 'a' in formatoptions 82vim . keymap . set ( "n" , "<leader>a" , function () 83local fo =vim . opt_local . formatoptions : get () 84if fo . a then 85vim . opt_local . formatoptions : remove ( "a" ) 86( "Auto-formatting disabled" ) 87else 88vim . opt_local . formatoptions : append ( "a" ) 89( "Auto-formatting enabled" ) 90end 91end , { buffer =true , desc ="Toggle auto-formatting" } ) 92end , 93} ) 94-- Setup formatting on LSP attach 95-- vim.api.nvim_create_autocmd("LspAttach", { 96-- callback = function(args) 97-- local client = vim.lsp.get_client_by_id(args.data.client_id) 98-- 99-- if client and client.supports_method("textDocument/formatting") then 100-- vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI" }, { 101-- buffer = args.buf, 102-- callback = function() 103-- vim.lsp.buf.format({ 104-- async = true, 105-- bufnr = args.buf, 106-- }) 107-- end, 108-- }) 109-- end 110-- end, 111-- }) 112 113vim . api . nvim_create_autocmd ( "TermOpen" , { 114pattern ="*" , 115callback =function () 116vim . opt_local . spell =false 117end , 118} ) 119 120vim . o . clipboard ="unnamedplus" 121 122-- vim.g.clipboard = { 123-- name = "OSC 52", 124-- copy = { 125-- ["+"] = require("vim.ui.clipboard.osc52").copy("+"), 126-- ["*"] = require("vim.ui.clipboard.osc52").copy("*"), 127-- }, 128-- paste = { 129-- ["+"] = require("vim.ui.clipboard.osc52").paste("+"), 130-- ["*"] = require("vim.ui.clipboard.osc52").paste("*"), 131-- }, 132-- } 133vim . g . clipboard ="osc52" 134vim . keymap . set ( "n" , "p" , '"+p' ) 135vim . keymap . set ( "n" , "P" , '"+P' ) 136 137 138-- stupid hacky workaround to make it so i can paste from tmux with OSC52 139-- https://github.com/neovim/neovim/discussions/29350#discussioncomment-10299517 140-- tracking issue about tmux behavior: https://github.com/tmux/tmux/issues/4275 141if vim . env . TMUX ~= nil then 142local copy ={ 'tmux' , 'load-buffer' , '-w' , '-' } 143local paste ={ 'bash' , '-c' , 'tmux refresh-client -l && sleep 0.05 && tmux save-buffer -' } 144vim . g . clipboard ={ 145name ='tmux' , 146copy ={ 147[ '+' ] =copy , 148[ '*' ] =copy , 149} , 150paste ={ 151[ '+' ] =paste , 152[ '*' ] =paste , 153} , 154cache_enabled =0 , 155} 156end 157 158-- https://simondalvai.org/blog/godot-neovim/ 159require ( "godot" )