blob: 5c40b75ac32477d035e2a91683e19488e4f69082 [file] [log] [blame]
Skyler Greyc96cd8a2022-06-15 12:28:27 +01001{ pkgs, ... }: {
Skyler Grey49c030f2022-08-12 11:48:56 +01002 programs.neovim = {
3 enable = true;
4 coc = {
5 enable = true;
6 settings = {
7 "suggest.noselect" = false;
Skyler Grey536f9092022-08-12 21:20:14 +01008 "cSpell.checkOnlyEnabledFileTypes" = false;
Skyler Grey49c030f2022-08-12 11:48:56 +01009 };
10 };
11 viAlias = true;
12 vimAlias = true;
13 vimdiffAlias = true;
14 extraConfig = ''
15 let mapleader = ","
16 let g:VM_leader = "\\"
17 set whichwrap=b,s,<,>,[,]
18 set linebreak
19 set wrap
20 set number
21 set cursorline
22 set expandtab
23 set mouse=a
24 set splitright
25 set splitbelow
26 set clipboard=unnamedplus
27 set ignorecase
28 set smartcase
Skyler Greyd948b222022-08-12 14:28:21 +010029 set nocompatible
30 set hidden
31 set encoding=utf-8
Skyler Grey49c030f2022-08-12 11:48:56 +010032 set scrolloff=5
33 colorscheme onehalfdark
Skyler Greya949ffd2022-06-23 23:32:48 +010034
Skyler Grey49c030f2022-08-12 11:48:56 +010035 command W w
36 command Wq wq
Skyler Grey6ad0c6d2022-08-10 09:54:25 +010037
Skyler Grey49c030f2022-08-12 11:48:56 +010038 fun! SetupCommandAlias(from, to)
Skyler Grey6ad0c6d2022-08-10 09:54:25 +010039 exec 'cnoreabbrev <expr> '.a:from
Skyler Grey49c030f2022-08-12 11:48:56 +010040 \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")'
41 \ .'? ("'.a:to.'") : ("'.a:from.'"))'
42 endfun
Skyler Grey6ad0c6d2022-08-10 09:54:25 +010043
Skyler Grey49c030f2022-08-12 11:48:56 +010044 call SetupCommandAlias("git","Git")
Skyler Grey6ad0c6d2022-08-10 09:54:25 +010045
Skyler Grey49c030f2022-08-12 11:48:56 +010046 let g:camelcasemotion_key = '<leader>'
Skyler Grey60fcac92022-08-10 08:21:42 +010047
Skyler Grey49c030f2022-08-12 11:48:56 +010048 if exists('+termguicolors')
Skyler Greya949ffd2022-06-23 23:32:48 +010049 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
50 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
51 set termguicolors
Skyler Grey8d2f1052022-07-09 21:02:17 +010052 endif
Skyler Grey8d2f1052022-07-09 21:02:17 +010053
Skyler Grey49c030f2022-08-12 11:48:56 +010054 let g:better_whitespace_enabled=1
55 let g:strip_whitespace_on_save=1
56 let g:strip_only_modified_lines=1
57 let g:strip_whitelines_at_eof=1
58 let g:show_spaces_that_precede_tabs=1
59 nnoremap ]w :NextTrailingWhitespace<CR>
60 nnoremap [w :PrevTrailingWhitespace<CR>
61
Skyler Grey849ee152022-08-12 13:30:07 +010062 let g:airline#extensions#tabline#enabled = 1
Skyler Greyd948b222022-08-12 14:28:21 +010063 let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
64 let g:airline_powerline_fonts = 1
Skyler Grey8bad2582022-08-12 15:17:20 +010065 let g:airline#extensions#hunks#coc_git = 1
66 let g:airline#extensions#whitespace#enabled = 1
67
Skyler Greyfceb6692022-08-12 16:56:59 +010068 nnoremap <silent> <leader>gg :LazyGit<CR>
69
Skyler Grey8bad2582022-08-12 15:17:20 +010070 let g:airline#extensions#tabline#buffer_idx_mode = 1
71 nmap <leader>1 <Plug>AirlineSelectTab1
72 nmap <leader>2 <Plug>AirlineSelectTab2
73 nmap <leader>3 <Plug>AirlineSelectTab3
74 nmap <leader>4 <Plug>AirlineSelectTab4
75 nmap <leader>5 <Plug>AirlineSelectTab5
76 nmap <leader>6 <Plug>AirlineSelectTab6
77 nmap <leader>7 <Plug>AirlineSelectTab7
78 nmap <leader>8 <Plug>AirlineSelectTab8
79 nmap <leader>9 <Plug>AirlineSelectTab9
80 nmap <leader>0 <Plug>AirlineSelectTab0
81 nmap <leader>- <Plug>AirlineSelectPrevTab
82 nmap <leader>+ <Plug>AirlineSelectNextTab
Skyler Grey8bad2582022-08-12 15:17:20 +010083 let g:airline_skip_empty_sections = 1
Skyler Greyd948b222022-08-12 14:28:21 +010084
85 let g:ctrlp_map = '<c-p>'
86 let g:ctrlp_cmd = 'CtrlP'
Skyler Grey849ee152022-08-12 13:30:07 +010087
Skyler Grey49c030f2022-08-12 11:48:56 +010088 nmap <silent> ]c :call CocAction('diagnosticNext')<cr>
89 nmap <silent> [c :call CocAction('diagnosticPrevious')<cr>
90 nmap <silent> <Leader>fs <Plug>(coc-codeaction-selected)
91 nmap <silent> <Leader>fg <Plug>(coc-codeaction-cursor)
92 nmap <silent> <Leader>ff <Plug>(coc-codeaction)
93 nmap <Leader>fe <Cmd>CocCommand explorer<CR>
94
95 vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
96
97 set statusline=%t "tail of the filename
98 set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
99 set statusline+=%{&ff}] "file format
100 set statusline+=%h "help file flag
101 set statusline+=%m "modified flag
102 set statusline+=%r "read only flag
103 set statusline+=%y "filetype
104 set statusline+=%= "left/right separator
105 set statusline+=%c, "cursor column
106 set statusline+=%l/%L "cursor line/total lines
107 set statusline+=\ %P "percent through file
108
109 let g:VM_theme_set_by_colorscheme = 1
110 highlight VM_Extend ctermfg=NONE guifg=NONE ctermbg=239 guibg=#474e5d
111 highlight VM_Cursor ctermfg=188 guifg=#dcdfe4 ctermbg=168 guibg=#e06c75
112 highlight VM_Insert ctermfg=236 guifg=#282c34 ctermbg=176 guibg=#c678dd
113 highlight VM_Mono ctermfg=236 guifg=#282c34 ctermbg=75 guibg=#61afef
114
115 highlight Pmenu ctermfg=188 guifg=#dcdfe4 ctermbg=239 guibg=#474e5d
116 highlight PmenuSel ctermfg=236 guifg=#282c34 ctermbg=75 guibg=#61afef
117 highlight PmenuSbar ctermfg=237 guifg=#313640 ctermbg=237 guibg=#313640
118 highlight PmenuThumb ctermfg=188 guifg=#dcdfe4 ctermbg=188 guibg=#dcdfe4
119
120 highlight CocErrorSign ctermfg=168 guifg=#e06c75 ctermbg=NONE guibg=NONE
121 highlight CocInfoSign ctermfg=75 guifg=#61afef ctermbg=NONE guibg=NONE
122 highlight CocWarningSign ctermfg=180 guifg=#e5c07b ctermbg=NONE guibg=NONE
123
124 nnoremap <silent> K :call <SID>show_documentation()<CR>
125
126 autocmd BufWritePre * Neoformat
127
128 let g:neoformat_try_node_exe = 1
129
130 function! s:show_documentation()
131 if (index(['vim','help'], &filetype) >= 0)
132 execute 'h '.expand('<cword>')
133 else
134 call CocAction('doHover')
135 endif
136 endfunction
137
138 lua << EOF
Skyler Grey686ca7f2022-06-24 14:30:05 +0100139 require('neorg').setup {
Skyler Grey49c030f2022-08-12 11:48:56 +0100140 load = {
141 ["core.defaults"] = {}
142 }
Skyler Grey686ca7f2022-06-24 14:30:05 +0100143 }
Skyler Grey55109532022-07-04 18:31:29 +0100144
Skyler Greyb3283572022-06-24 21:25:29 +0100145 require('orgmode').setup_ts_grammar()
Skyler Grey810c00e2022-06-24 21:16:22 +0100146
147 require('nvim-treesitter.configs').setup {
Skyler Grey49c030f2022-08-12 11:48:56 +0100148 highlight = {
149 enable = true,
150 additional_vim_regex_highlighting = {'org'},
Skyler Grey4597d652022-08-03 00:23:19 +0100151 },
Skyler Grey49c030f2022-08-12 11:48:56 +0100152 rainbow = {
153 enable = true,
154 extended_mode = true,
155 max_file_lines = nil,
156 },
157 incremental_selection = {
158 enable = true,
159 keymaps = {
160 init_selection = "gnn",
161 node_incremental = "grn",
162 scope_incremental = "grc",
163 node_decremental = "grm",
164 },
165 },
166 indent = {
167 enable = true,
168 },
Skyler Grey810c00e2022-06-24 21:16:22 +0100169 }
Skyler Greyc0a52452022-07-09 21:06:53 +0100170
171 require('git-conflict').setup()
Skyler Grey49c030f2022-08-12 11:48:56 +0100172 EOF
Skyler Grey4597d652022-08-03 00:23:19 +0100173
Skyler Grey49c030f2022-08-12 11:48:56 +0100174 set foldmethod=expr
175 set foldexpr=nvim_treesitter#foldexpr()
Skyler Grey36eef4e2022-08-03 00:37:44 +0100176
Skyler Grey49c030f2022-08-12 11:48:56 +0100177 set viewoptions-=options
178 autocmd BufWinLeave ?* mkview!
179 autocmd BufWinEnter ?* normal zR
Skyler Greydfd501b2022-08-11 09:48:47 +0100180
Skyler Grey49c030f2022-08-12 11:48:56 +0100181 function! s:loadViewOrUnfold()
Skyler Greydfd501b2022-08-11 09:48:47 +0100182 try
Skyler Grey49c030f2022-08-12 11:48:56 +0100183 loadview
Skyler Greydfd501b2022-08-11 09:48:47 +0100184 catch
Skyler Grey49c030f2022-08-12 11:48:56 +0100185 folddoclosed foldopen
Skyler Greydfd501b2022-08-11 09:48:47 +0100186 endtry
Skyler Grey49c030f2022-08-12 11:48:56 +0100187 endfunction
Skyler Greydfd501b2022-08-11 09:48:47 +0100188
Skyler Grey49c030f2022-08-12 11:48:56 +0100189 autocmd BufWinEnter ?* call s:loadViewOrUnfold()
Skyler Greyd948b222022-08-12 14:28:21 +0100190
191
192 :let g:airline_highlighting_cache = 1
Skyler Grey8bad2582022-08-12 15:17:20 +0100193 autocmd VimEnter * call vista#RunForNearestMethodOrFunction()
Skyler Grey49c030f2022-08-12 11:48:56 +0100194 '';
Skyler Grey686ca7f2022-06-24 14:30:05 +0100195
Skyler Grey1dc04f22022-08-12 21:04:38 +0100196 plugins = with pkgs.vimPlugins; [
197 git-conflict-nvim
198 vim-nix
199 copilot-vim
200 coc-tsserver
201 coc-eslint
202 coc-rust-analyzer
203 coc-spell-checker
204 coc-json
205 coc-jest
206 coc-css
207 coc-explorer
208 coc-git
209 neoformat
210 zoomwintab-vim
211 onehalf
212 neorg
213 orgmode
214 vim-sleuth
215 vim-visual-multi
216 vim-better-whitespace
217 nvim-ts-rainbow
218 editorconfig-nvim
219 camelcasemotion
220 fugitive
221 vim-flog
222 airline
223 vista-vim
224 vim-gitgutter
225 ctrlp-vim
226 vim-airline-clock
227 vim-airline-themes
228 lazygit-nvim
229 (nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars))
Skyler Grey49c030f2022-08-12 11:48:56 +0100230 ];
231 };
Skyler Greyc96cd8a2022-06-15 12:28:27 +0100232
Skyler Grey1dc04f22022-08-12 21:04:38 +0100233 home.packages = with pkgs; [
234 universal-ctags
235 nodePackages.cspell
Skyler Greyd948b222022-08-12 14:28:21 +0100236 ];
237
Skyler Grey49c030f2022-08-12 11:48:56 +0100238 home.sessionVariables.EDITOR = "${pkgs.neovim}/bin/nvim";
Skyler Grey73c55fc2022-06-12 09:18:59 +0100239}