blob: 0e3b231fb3dbe13c2052ca560ba83d9c928525e5 [file] [log] [blame]
Skyler Greyc96cd8a2022-06-15 12:28:27 +01001{ pkgs, ... }: {
Skyler Greye6995322022-06-12 09:29:17 +01002 programs.neovim = {
3 enable = true;
Skyler Greyc96cd8a2022-06-15 12:28:27 +01004 coc = {
5 enable = true;
6 settings = {
7 "suggest.noselect" = false;
8 };
9 };
Skyler Greye6995322022-06-12 09:29:17 +010010 viAlias = true;
11 vimAlias = true;
12 vimdiffAlias = true;
Skyler Greyc96cd8a2022-06-15 12:28:27 +010013 extraConfig = ''
Skyler Grey60fcac92022-08-10 08:21:42 +010014 let mapleader = ","
Skyler Greyc96cd8a2022-06-15 12:28:27 +010015 set whichwrap=b,s,<,>,[,]
Skyler Greya3999c02022-06-24 14:05:13 +010016 set linebreak
Skyler Grey2e80a192022-06-15 14:23:01 +010017 set wrap
18 set number
Skyler Greya949ffd2022-06-23 23:32:48 +010019 set cursorline
Skyler Grey32da1932022-07-05 08:37:59 +010020 set expandtab
Skyler Grey8d2f1052022-07-09 21:02:17 +010021 set mouse=a
Skyler Greya0b7aea2022-07-12 12:01:49 +010022 set splitright
Skyler Grey1e4cbc72022-07-12 12:39:02 +010023 set splitbelow
Skyler Grey41966112022-07-09 21:38:53 +010024 set clipboard=unnamedplus
Skyler Grey1db04f72022-08-10 12:11:19 +010025 set ignorecase
Skyler Grey0bd95942022-07-27 13:16:29 +010026 set smartcase
Skyler Grey5f20cf22022-08-04 21:59:38 +010027 set scrolloff=5
Skyler Greya949ffd2022-06-23 23:32:48 +010028 colorscheme onehalfdark
29
Skyler Grey6ad0c6d2022-08-10 09:54:25 +010030 command W w
31 command Wq wq
32
33 fun! SetupCommandAlias(from, to)
34 exec 'cnoreabbrev <expr> '.a:from
35 \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")'
36 \ .'? ("'.a:to.'") : ("'.a:from.'"))'
37 endfun
38
39 call SetupCommandAlias("git","Git")
40
Skyler Grey60fcac92022-08-10 08:21:42 +010041 let g:camelcasemotion_key = '<leader>'
42
Skyler Greya949ffd2022-06-23 23:32:48 +010043 if exists('+termguicolors')
44 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
45 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
46 set termguicolors
47 endif
Skyler Grey48028522022-06-23 23:37:22 +010048
Skyler Grey76d302d2022-08-02 23:15:29 +010049 let g:better_whitespace_enabled=1
50 let g:strip_whitespace_on_save=1
51 let g:strip_only_modified_lines=1
52 let g:strip_whitelines_at_eof=1
53 let g:show_spaces_that_precede_tabs=1
54 nnoremap ]w :NextTrailingWhitespace<CR>
55 nnoremap [w :PrevTrailingWhitespace<CR>
Skyler Grey686ca7f2022-06-24 14:30:05 +010056
Skyler Grey9963f392022-08-06 13:05:56 +010057 nmap <silent> ]c :call CocAction('diagnosticNext')<cr>
58 nmap <silent> [c :call CocAction('diagnosticPrevious')<cr>
Skyler Greybc1490d2022-08-10 11:39:19 +010059 nmap <silent> <Leader>fs <Plug>(coc-codeaction-selected)
Skyler Greyd98ed502022-08-10 11:41:00 +010060 nmap <silent> <Leader>fg <Plug>(coc-codeaction-cursor)
61 nmap <silent> <Leader>ff <Plug>(coc-codeaction)
Skyler Grey2c76ca12022-08-10 13:07:55 +010062 nmap <Leader>fe <Cmd>CocCommand explorer<CR>
Skyler Grey4dad3c12022-08-04 22:15:51 +010063
Skyler Greya637b852022-08-11 09:58:23 +010064 vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
65
Skyler Grey48028522022-06-23 23:37:22 +010066 set statusline=%t "tail of the filename
67 set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
68 set statusline+=%{&ff}] "file format
69 set statusline+=%h "help file flag
70 set statusline+=%m "modified flag
71 set statusline+=%r "read only flag
72 set statusline+=%y "filetype
73 set statusline+=%= "left/right separator
74 set statusline+=%c, "cursor column
75 set statusline+=%l/%L "cursor line/total lines
76 set statusline+=\ %P "percent through file
Skyler Grey686ca7f2022-06-24 14:30:05 +010077
Skyler Grey76d302d2022-08-02 23:15:29 +010078 let g:VM_theme_set_by_colorscheme = 1
79 highlight VM_Extend ctermfg=NONE guifg=NONE ctermbg=239 guibg=#474e5d
80 highlight VM_Cursor ctermfg=188 guifg=#dcdfe4 ctermbg=168 guibg=#e06c75
81 highlight VM_Insert ctermfg=236 guifg=#282c34 ctermbg=176 guibg=#c678dd
82 highlight VM_Mono ctermfg=236 guifg=#282c34 ctermbg=75 guibg=#61afef
83
Skyler Greyb4d02842022-08-06 09:18:51 +010084 highlight Pmenu ctermfg=188 guifg=#dcdfe4 ctermbg=239 guibg=#474e5d
85 highlight PmenuSel ctermfg=236 guifg=#282c34 ctermbg=75 guibg=#61afef
86 highlight PmenuSbar ctermfg=237 guifg=#313640 ctermbg=237 guibg=#313640
87 highlight PmenuThumb ctermfg=188 guifg=#dcdfe4 ctermbg=188 guibg=#dcdfe4
88
Skyler Grey40ebe3c2022-08-06 09:57:57 +010089 highlight CocErrorSign ctermfg=168 guifg=#e06c75 ctermbg=NONE guibg=NONE
90 highlight CocInfoSign ctermfg=75 guifg=#61afef ctermbg=NONE guibg=NONE
91 highlight CocWarningSign ctermfg=180 guifg=#e5c07b ctermbg=NONE guibg=NONE
92
Skyler Grey8d2f1052022-07-09 21:02:17 +010093 nnoremap <silent> K :call <SID>show_documentation()<CR>
94
Skyler Grey16894302022-08-06 12:36:27 +010095 autocmd BufWritePre * Neoformat
Skyler Greybee13672022-08-06 12:18:24 +010096
97 let g:neoformat_try_node_exe = 1
98
Skyler Grey8d2f1052022-07-09 21:02:17 +010099 function! s:show_documentation()
100 if (index(['vim','help'], &filetype) >= 0)
101 execute 'h '.expand('<cword>')
102 else
103 call CocAction('doHover')
104 endif
105 endfunction
106
Skyler Grey686ca7f2022-06-24 14:30:05 +0100107 lua << EOF
108 require('neorg').setup {
109 load = {
110 ["core.defaults"] = {}
111 }
112 }
Skyler Grey55109532022-07-04 18:31:29 +0100113
Skyler Greyb3283572022-06-24 21:25:29 +0100114 require('orgmode').setup_ts_grammar()
Skyler Grey810c00e2022-06-24 21:16:22 +0100115
116 require('nvim-treesitter.configs').setup {
117 highlight = {
118 enable = true,
Skyler Greyb3283572022-06-24 21:25:29 +0100119 additional_vim_regex_highlighting = {'org'},
Skyler Grey810c00e2022-06-24 21:16:22 +0100120 },
Skyler Grey76d302d2022-08-02 23:15:29 +0100121 rainbow = {
122 enable = true,
123 extended_mode = true,
124 max_file_lines = nil,
125 },
Skyler Grey4597d652022-08-03 00:23:19 +0100126 incremental_selection = {
127 enable = true,
128 keymaps = {
129 init_selection = "gnn",
130 node_incremental = "grn",
131 scope_incremental = "grc",
132 node_decremental = "grm",
133 },
134 },
Skyler Grey810c00e2022-06-24 21:16:22 +0100135 indent = {
136 enable = true,
137 },
138 }
Skyler Greyc0a52452022-07-09 21:06:53 +0100139
140 require('git-conflict').setup()
Skyler Grey686ca7f2022-06-24 14:30:05 +0100141 EOF
Skyler Grey4597d652022-08-03 00:23:19 +0100142
143 set foldmethod=expr
144 set foldexpr=nvim_treesitter#foldexpr()
Skyler Grey36eef4e2022-08-03 00:37:44 +0100145
146 set viewoptions-=options
147 autocmd BufWinLeave ?* mkview!
148 autocmd BufWinEnter ?* normal zR
Skyler Greydfd501b2022-08-11 09:48:47 +0100149
150 function! s:loadViewOrUnfold()
151 try
152 loadview
153 catch
154 folddoclosed foldopen
155 endtry
156 endfunction
157
Skyler Greyc24fc8e2022-08-11 11:27:53 +0100158 autocmd BufWinEnter ?* call s:loadViewOrUnfold()
Skyler Greyc96cd8a2022-06-15 12:28:27 +0100159 '';
Skyler Grey686ca7f2022-06-24 14:30:05 +0100160
Skyler Greyc96cd8a2022-06-15 12:28:27 +0100161 plugins = [
Skyler Grey8d2f1052022-07-09 21:02:17 +0100162 pkgs.vimPlugins.git-conflict-nvim
Skyler Greyc96cd8a2022-06-15 12:28:27 +0100163 pkgs.vimPlugins.vim-nix
Skyler Greye96d0112022-06-15 15:39:56 +0100164 pkgs.vimPlugins.copilot-vim
Skyler Greyf2b5e262022-06-15 15:59:50 +0100165 pkgs.vimPlugins.coc-tsserver
Skyler Grey55109532022-07-04 18:31:29 +0100166 pkgs.vimPlugins.coc-eslint
Skyler Grey78260a22022-08-06 11:29:45 +0100167 pkgs.vimPlugins.coc-rust-analyzer
168 pkgs.vimPlugins.coc-spell-checker
169 pkgs.vimPlugins.coc-json
170 pkgs.vimPlugins.coc-jest
171 pkgs.vimPlugins.coc-css
172 pkgs.vimPlugins.coc-explorer
173 pkgs.vimPlugins.neoformat
Skyler Grey58867232022-06-23 22:02:10 +0100174 pkgs.vimPlugins.zoomwintab-vim
175 pkgs.vimPlugins.onehalf
Skyler Grey619d8602022-06-24 14:20:51 +0100176 pkgs.vimPlugins.neorg
Skyler Greyb3283572022-06-24 21:25:29 +0100177 pkgs.vimPlugins.orgmode
Skyler Greyf49e4f32022-07-20 20:47:35 +0100178 pkgs.vimPlugins.vim-sleuth
Skyler Grey249d9d02022-07-12 13:19:17 +0100179 pkgs.vimPlugins.vim-visual-multi
Skyler Grey76d302d2022-08-02 23:15:29 +0100180 pkgs.vimPlugins.vim-better-whitespace
Skyler Grey8ae90a22022-08-04 10:34:25 +0100181 pkgs.vimPlugins.nvim-ts-rainbow
Skyler Greye61027a2022-08-06 12:22:29 +0100182 pkgs.vimPlugins.editorconfig-nvim
Skyler Grey25b96522022-08-09 09:00:52 +0100183 pkgs.vimPlugins.camelcasemotion
Skyler Greydc7de362022-08-10 09:48:09 +0100184 pkgs.vimPlugins.fugitive
Skyler Grey8ae90a22022-08-04 10:34:25 +0100185 (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars))
Skyler Greyc96cd8a2022-06-15 12:28:27 +0100186 ];
Skyler Greye6995322022-06-12 09:29:17 +0100187 };
Skyler Greyc96cd8a2022-06-15 12:28:27 +0100188
189 home.sessionVariables.EDITOR = "${pkgs.neovim}/bin/nvim";
Skyler Grey73c55fc2022-06-12 09:18:59 +0100190}