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