blob: a01add68ffa63aa56dfbc7da709b13f2afb61523 [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
67 let g:airline#extensions#tabline#buffer_idx_mode = 1
68 nmap <leader>1 <Plug>AirlineSelectTab1
69 nmap <leader>2 <Plug>AirlineSelectTab2
70 nmap <leader>3 <Plug>AirlineSelectTab3
71 nmap <leader>4 <Plug>AirlineSelectTab4
72 nmap <leader>5 <Plug>AirlineSelectTab5
73 nmap <leader>6 <Plug>AirlineSelectTab6
74 nmap <leader>7 <Plug>AirlineSelectTab7
75 nmap <leader>8 <Plug>AirlineSelectTab8
76 nmap <leader>9 <Plug>AirlineSelectTab9
77 nmap <leader>0 <Plug>AirlineSelectTab0
78 nmap <leader>- <Plug>AirlineSelectPrevTab
79 nmap <leader>+ <Plug>AirlineSelectNextTab
80 let airline#extensions#tabline#middle_click_preserves_windows = 1
Skyler Grey8bad2582022-08-12 15:17:20 +010081 let g:airline_skip_empty_sections = 1
Skyler Greyd948b222022-08-12 14:28:21 +010082
83 let g:ctrlp_map = '<c-p>'
84 let g:ctrlp_cmd = 'CtrlP'
Skyler Grey849ee152022-08-12 13:30:07 +010085
Skyler Grey49c030f2022-08-12 11:48:56 +010086 nmap <silent> ]c :call CocAction('diagnosticNext')<cr>
87 nmap <silent> [c :call CocAction('diagnosticPrevious')<cr>
88 nmap <silent> <Leader>fs <Plug>(coc-codeaction-selected)
89 nmap <silent> <Leader>fg <Plug>(coc-codeaction-cursor)
90 nmap <silent> <Leader>ff <Plug>(coc-codeaction)
91 nmap <Leader>fe <Cmd>CocCommand explorer<CR>
92
93 vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
94
95 set statusline=%t "tail of the filename
96 set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
97 set statusline+=%{&ff}] "file format
98 set statusline+=%h "help file flag
99 set statusline+=%m "modified flag
100 set statusline+=%r "read only flag
101 set statusline+=%y "filetype
102 set statusline+=%= "left/right separator
103 set statusline+=%c, "cursor column
104 set statusline+=%l/%L "cursor line/total lines
105 set statusline+=\ %P "percent through file
106
107 let g:VM_theme_set_by_colorscheme = 1
108 highlight VM_Extend ctermfg=NONE guifg=NONE ctermbg=239 guibg=#474e5d
109 highlight VM_Cursor ctermfg=188 guifg=#dcdfe4 ctermbg=168 guibg=#e06c75
110 highlight VM_Insert ctermfg=236 guifg=#282c34 ctermbg=176 guibg=#c678dd
111 highlight VM_Mono ctermfg=236 guifg=#282c34 ctermbg=75 guibg=#61afef
112
113 highlight Pmenu ctermfg=188 guifg=#dcdfe4 ctermbg=239 guibg=#474e5d
114 highlight PmenuSel ctermfg=236 guifg=#282c34 ctermbg=75 guibg=#61afef
115 highlight PmenuSbar ctermfg=237 guifg=#313640 ctermbg=237 guibg=#313640
116 highlight PmenuThumb ctermfg=188 guifg=#dcdfe4 ctermbg=188 guibg=#dcdfe4
117
118 highlight CocErrorSign ctermfg=168 guifg=#e06c75 ctermbg=NONE guibg=NONE
119 highlight CocInfoSign ctermfg=75 guifg=#61afef ctermbg=NONE guibg=NONE
120 highlight CocWarningSign ctermfg=180 guifg=#e5c07b ctermbg=NONE guibg=NONE
121
122 nnoremap <silent> K :call <SID>show_documentation()<CR>
123
124 autocmd BufWritePre * Neoformat
125
126 let g:neoformat_try_node_exe = 1
127
128 function! s:show_documentation()
129 if (index(['vim','help'], &filetype) >= 0)
130 execute 'h '.expand('<cword>')
131 else
132 call CocAction('doHover')
133 endif
134 endfunction
135
136 lua << EOF
Skyler Grey686ca7f2022-06-24 14:30:05 +0100137 require('neorg').setup {
Skyler Grey49c030f2022-08-12 11:48:56 +0100138 load = {
139 ["core.defaults"] = {}
140 }
Skyler Grey686ca7f2022-06-24 14:30:05 +0100141 }
Skyler Grey55109532022-07-04 18:31:29 +0100142
Skyler Greyb3283572022-06-24 21:25:29 +0100143 require('orgmode').setup_ts_grammar()
Skyler Grey810c00e2022-06-24 21:16:22 +0100144
145 require('nvim-treesitter.configs').setup {
Skyler Grey49c030f2022-08-12 11:48:56 +0100146 highlight = {
147 enable = true,
148 additional_vim_regex_highlighting = {'org'},
Skyler Grey4597d652022-08-03 00:23:19 +0100149 },
Skyler Grey49c030f2022-08-12 11:48:56 +0100150 rainbow = {
151 enable = true,
152 extended_mode = true,
153 max_file_lines = nil,
154 },
155 incremental_selection = {
156 enable = true,
157 keymaps = {
158 init_selection = "gnn",
159 node_incremental = "grn",
160 scope_incremental = "grc",
161 node_decremental = "grm",
162 },
163 },
164 indent = {
165 enable = true,
166 },
Skyler Grey810c00e2022-06-24 21:16:22 +0100167 }
Skyler Greyc0a52452022-07-09 21:06:53 +0100168
169 require('git-conflict').setup()
Skyler Grey49c030f2022-08-12 11:48:56 +0100170 EOF
Skyler Grey4597d652022-08-03 00:23:19 +0100171
Skyler Grey49c030f2022-08-12 11:48:56 +0100172 set foldmethod=expr
173 set foldexpr=nvim_treesitter#foldexpr()
Skyler Grey36eef4e2022-08-03 00:37:44 +0100174
Skyler Grey49c030f2022-08-12 11:48:56 +0100175 set viewoptions-=options
176 autocmd BufWinLeave ?* mkview!
177 autocmd BufWinEnter ?* normal zR
Skyler Greydfd501b2022-08-11 09:48:47 +0100178
Skyler Grey49c030f2022-08-12 11:48:56 +0100179 function! s:loadViewOrUnfold()
Skyler Greydfd501b2022-08-11 09:48:47 +0100180 try
Skyler Grey49c030f2022-08-12 11:48:56 +0100181 loadview
Skyler Greydfd501b2022-08-11 09:48:47 +0100182 catch
Skyler Grey49c030f2022-08-12 11:48:56 +0100183 folddoclosed foldopen
Skyler Greydfd501b2022-08-11 09:48:47 +0100184 endtry
Skyler Grey49c030f2022-08-12 11:48:56 +0100185 endfunction
Skyler Greydfd501b2022-08-11 09:48:47 +0100186
Skyler Grey49c030f2022-08-12 11:48:56 +0100187 autocmd BufWinEnter ?* call s:loadViewOrUnfold()
Skyler Greyd948b222022-08-12 14:28:21 +0100188
189
190 :let g:airline_highlighting_cache = 1
Skyler Grey8bad2582022-08-12 15:17:20 +0100191 autocmd VimEnter * call vista#RunForNearestMethodOrFunction()
Skyler Grey49c030f2022-08-12 11:48:56 +0100192 '';
Skyler Grey686ca7f2022-06-24 14:30:05 +0100193
Skyler Grey49c030f2022-08-12 11:48:56 +0100194 plugins = [
195 pkgs.vimPlugins.git-conflict-nvim
196 pkgs.vimPlugins.vim-nix
197 pkgs.vimPlugins.copilot-vim
198 pkgs.vimPlugins.coc-tsserver
199 pkgs.vimPlugins.coc-eslint
200 pkgs.vimPlugins.coc-rust-analyzer
201 pkgs.vimPlugins.coc-spell-checker
202 pkgs.vimPlugins.coc-json
203 pkgs.vimPlugins.coc-jest
204 pkgs.vimPlugins.coc-css
205 pkgs.vimPlugins.coc-explorer
Skyler Greyd948b222022-08-12 14:28:21 +0100206 pkgs.vimPlugins.coc-git
Skyler Grey49c030f2022-08-12 11:48:56 +0100207 pkgs.vimPlugins.neoformat
208 pkgs.vimPlugins.zoomwintab-vim
209 pkgs.vimPlugins.onehalf
210 pkgs.vimPlugins.neorg
211 pkgs.vimPlugins.orgmode
212 pkgs.vimPlugins.vim-sleuth
213 pkgs.vimPlugins.vim-visual-multi
214 pkgs.vimPlugins.vim-better-whitespace
215 pkgs.vimPlugins.nvim-ts-rainbow
216 pkgs.vimPlugins.editorconfig-nvim
217 pkgs.vimPlugins.camelcasemotion
218 pkgs.vimPlugins.fugitive
Skyler Greyd948b222022-08-12 14:28:21 +0100219 pkgs.vimPlugins.vim-flog
Skyler Grey849ee152022-08-12 13:30:07 +0100220 pkgs.vimPlugins.airline
Skyler Grey8bad2582022-08-12 15:17:20 +0100221 pkgs.vimPlugins.vista-vim
Skyler Greyd948b222022-08-12 14:28:21 +0100222 pkgs.vimPlugins.vim-gitgutter
223 pkgs.vimPlugins.ctrlp-vim
Skyler Grey8bad2582022-08-12 15:17:20 +0100224 pkgs.vimPlugins.vim-airline-clock
225 pkgs.vimPlugins.vim-airline-themes
Skyler Grey49c030f2022-08-12 11:48:56 +0100226 (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars))
227 ];
228 };
Skyler Greyc96cd8a2022-06-15 12:28:27 +0100229
Skyler Greyd948b222022-08-12 14:28:21 +0100230 home.packages = [
231 pkgs.universal-ctags
232 ];
233
Skyler Grey49c030f2022-08-12 11:48:56 +0100234 home.sessionVariables.EDITOR = "${pkgs.neovim}/bin/nvim";
Skyler Grey73c55fc2022-06-12 09:18:59 +0100235}