blob: e5a1bbc26d71a37d33083f50fc121abd5c181104 [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
28 set scrolloff=5
29 colorscheme onehalfdark
Skyler Greya949ffd2022-06-23 23:32:48 +010030
Skyler Grey49c030f2022-08-12 11:48:56 +010031 command W w
32 command Wq wq
Skyler Grey6ad0c6d2022-08-10 09:54:25 +010033
Skyler Grey49c030f2022-08-12 11:48:56 +010034 fun! SetupCommandAlias(from, to)
Skyler Grey6ad0c6d2022-08-10 09:54:25 +010035 exec 'cnoreabbrev <expr> '.a:from
Skyler Grey49c030f2022-08-12 11:48:56 +010036 \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")'
37 \ .'? ("'.a:to.'") : ("'.a:from.'"))'
38 endfun
Skyler Grey6ad0c6d2022-08-10 09:54:25 +010039
Skyler Grey49c030f2022-08-12 11:48:56 +010040 call SetupCommandAlias("git","Git")
Skyler Grey6ad0c6d2022-08-10 09:54:25 +010041
Skyler Grey49c030f2022-08-12 11:48:56 +010042 let g:camelcasemotion_key = '<leader>'
Skyler Grey60fcac92022-08-10 08:21:42 +010043
Skyler Grey49c030f2022-08-12 11:48:56 +010044 if exists('+termguicolors')
Skyler Greya949ffd2022-06-23 23:32:48 +010045 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
46 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
47 set termguicolors
Skyler Grey8d2f1052022-07-09 21:02:17 +010048 endif
Skyler Grey8d2f1052022-07-09 21:02:17 +010049
Skyler Grey49c030f2022-08-12 11:48:56 +010050 let g:better_whitespace_enabled=1
51 let g:strip_whitespace_on_save=1
52 let g:strip_only_modified_lines=1
53 let g:strip_whitelines_at_eof=1
54 let g:show_spaces_that_precede_tabs=1
55 nnoremap ]w :NextTrailingWhitespace<CR>
56 nnoremap [w :PrevTrailingWhitespace<CR>
57
Skyler Grey849ee152022-08-12 13:30:07 +010058 let g:airline#extensions#tabline#enabled = 1
59
Skyler Grey49c030f2022-08-12 11:48:56 +010060 nmap <silent> ]c :call CocAction('diagnosticNext')<cr>
61 nmap <silent> [c :call CocAction('diagnosticPrevious')<cr>
62 nmap <silent> <Leader>fs <Plug>(coc-codeaction-selected)
63 nmap <silent> <Leader>fg <Plug>(coc-codeaction-cursor)
64 nmap <silent> <Leader>ff <Plug>(coc-codeaction)
65 nmap <Leader>fe <Cmd>CocCommand explorer<CR>
66
67 vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
68
69 set statusline=%t "tail of the filename
70 set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
71 set statusline+=%{&ff}] "file format
72 set statusline+=%h "help file flag
73 set statusline+=%m "modified flag
74 set statusline+=%r "read only flag
75 set statusline+=%y "filetype
76 set statusline+=%= "left/right separator
77 set statusline+=%c, "cursor column
78 set statusline+=%l/%L "cursor line/total lines
79 set statusline+=\ %P "percent through file
80
81 let g:VM_theme_set_by_colorscheme = 1
82 highlight VM_Extend ctermfg=NONE guifg=NONE ctermbg=239 guibg=#474e5d
83 highlight VM_Cursor ctermfg=188 guifg=#dcdfe4 ctermbg=168 guibg=#e06c75
84 highlight VM_Insert ctermfg=236 guifg=#282c34 ctermbg=176 guibg=#c678dd
85 highlight VM_Mono ctermfg=236 guifg=#282c34 ctermbg=75 guibg=#61afef
86
87 highlight Pmenu ctermfg=188 guifg=#dcdfe4 ctermbg=239 guibg=#474e5d
88 highlight PmenuSel ctermfg=236 guifg=#282c34 ctermbg=75 guibg=#61afef
89 highlight PmenuSbar ctermfg=237 guifg=#313640 ctermbg=237 guibg=#313640
90 highlight PmenuThumb ctermfg=188 guifg=#dcdfe4 ctermbg=188 guibg=#dcdfe4
91
92 highlight CocErrorSign ctermfg=168 guifg=#e06c75 ctermbg=NONE guibg=NONE
93 highlight CocInfoSign ctermfg=75 guifg=#61afef ctermbg=NONE guibg=NONE
94 highlight CocWarningSign ctermfg=180 guifg=#e5c07b ctermbg=NONE guibg=NONE
95
96 nnoremap <silent> K :call <SID>show_documentation()<CR>
97
98 autocmd BufWritePre * Neoformat
99
100 let g:neoformat_try_node_exe = 1
101
102 function! s:show_documentation()
103 if (index(['vim','help'], &filetype) >= 0)
104 execute 'h '.expand('<cword>')
105 else
106 call CocAction('doHover')
107 endif
108 endfunction
109
110 lua << EOF
Skyler Grey686ca7f2022-06-24 14:30:05 +0100111 require('neorg').setup {
Skyler Grey49c030f2022-08-12 11:48:56 +0100112 load = {
113 ["core.defaults"] = {}
114 }
Skyler Grey686ca7f2022-06-24 14:30:05 +0100115 }
Skyler Grey55109532022-07-04 18:31:29 +0100116
Skyler Greyb3283572022-06-24 21:25:29 +0100117 require('orgmode').setup_ts_grammar()
Skyler Grey810c00e2022-06-24 21:16:22 +0100118
119 require('nvim-treesitter.configs').setup {
Skyler Grey49c030f2022-08-12 11:48:56 +0100120 highlight = {
121 enable = true,
122 additional_vim_regex_highlighting = {'org'},
Skyler Grey4597d652022-08-03 00:23:19 +0100123 },
Skyler Grey49c030f2022-08-12 11:48:56 +0100124 rainbow = {
125 enable = true,
126 extended_mode = true,
127 max_file_lines = nil,
128 },
129 incremental_selection = {
130 enable = true,
131 keymaps = {
132 init_selection = "gnn",
133 node_incremental = "grn",
134 scope_incremental = "grc",
135 node_decremental = "grm",
136 },
137 },
138 indent = {
139 enable = true,
140 },
Skyler Grey810c00e2022-06-24 21:16:22 +0100141 }
Skyler Greyc0a52452022-07-09 21:06:53 +0100142
143 require('git-conflict').setup()
Skyler Grey49c030f2022-08-12 11:48:56 +0100144 EOF
Skyler Grey4597d652022-08-03 00:23:19 +0100145
Skyler Grey49c030f2022-08-12 11:48:56 +0100146 set foldmethod=expr
147 set foldexpr=nvim_treesitter#foldexpr()
Skyler Grey36eef4e2022-08-03 00:37:44 +0100148
Skyler Grey49c030f2022-08-12 11:48:56 +0100149 set viewoptions-=options
150 autocmd BufWinLeave ?* mkview!
151 autocmd BufWinEnter ?* normal zR
Skyler Greydfd501b2022-08-11 09:48:47 +0100152
Skyler Grey49c030f2022-08-12 11:48:56 +0100153 function! s:loadViewOrUnfold()
Skyler Greydfd501b2022-08-11 09:48:47 +0100154 try
Skyler Grey49c030f2022-08-12 11:48:56 +0100155 loadview
Skyler Greydfd501b2022-08-11 09:48:47 +0100156 catch
Skyler Grey49c030f2022-08-12 11:48:56 +0100157 folddoclosed foldopen
Skyler Greydfd501b2022-08-11 09:48:47 +0100158 endtry
Skyler Grey49c030f2022-08-12 11:48:56 +0100159 endfunction
Skyler Greydfd501b2022-08-11 09:48:47 +0100160
Skyler Grey49c030f2022-08-12 11:48:56 +0100161 autocmd BufWinEnter ?* call s:loadViewOrUnfold()
162 '';
Skyler Grey686ca7f2022-06-24 14:30:05 +0100163
Skyler Grey49c030f2022-08-12 11:48:56 +0100164 plugins = [
165 pkgs.vimPlugins.git-conflict-nvim
166 pkgs.vimPlugins.vim-nix
167 pkgs.vimPlugins.copilot-vim
168 pkgs.vimPlugins.coc-tsserver
169 pkgs.vimPlugins.coc-eslint
170 pkgs.vimPlugins.coc-rust-analyzer
171 pkgs.vimPlugins.coc-spell-checker
172 pkgs.vimPlugins.coc-json
173 pkgs.vimPlugins.coc-jest
174 pkgs.vimPlugins.coc-css
175 pkgs.vimPlugins.coc-explorer
176 pkgs.vimPlugins.neoformat
177 pkgs.vimPlugins.zoomwintab-vim
178 pkgs.vimPlugins.onehalf
179 pkgs.vimPlugins.neorg
180 pkgs.vimPlugins.orgmode
181 pkgs.vimPlugins.vim-sleuth
182 pkgs.vimPlugins.vim-visual-multi
183 pkgs.vimPlugins.vim-better-whitespace
184 pkgs.vimPlugins.nvim-ts-rainbow
185 pkgs.vimPlugins.editorconfig-nvim
186 pkgs.vimPlugins.camelcasemotion
187 pkgs.vimPlugins.fugitive
Skyler Grey849ee152022-08-12 13:30:07 +0100188 pkgs.vimPlugins.airline
Skyler Grey49c030f2022-08-12 11:48:56 +0100189 (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars))
190 ];
191 };
Skyler Greyc96cd8a2022-06-15 12:28:27 +0100192
Skyler Grey49c030f2022-08-12 11:48:56 +0100193 home.sessionVariables.EDITOR = "${pkgs.neovim}/bin/nvim";
Skyler Grey73c55fc2022-06-12 09:18:59 +0100194}