Skyler Grey | c96cd8a | 2022-06-15 12:28:27 +0100 | [diff] [blame] | 1 | { pkgs, ... }: { |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 2 | 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 Grey | a949ffd | 2022-06-23 23:32:48 +0100 | [diff] [blame] | 30 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 31 | command W w |
| 32 | command Wq wq |
Skyler Grey | 6ad0c6d | 2022-08-10 09:54:25 +0100 | [diff] [blame] | 33 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 34 | fun! SetupCommandAlias(from, to) |
Skyler Grey | 6ad0c6d | 2022-08-10 09:54:25 +0100 | [diff] [blame] | 35 | exec 'cnoreabbrev <expr> '.a:from |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 36 | \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")' |
| 37 | \ .'? ("'.a:to.'") : ("'.a:from.'"))' |
| 38 | endfun |
Skyler Grey | 6ad0c6d | 2022-08-10 09:54:25 +0100 | [diff] [blame] | 39 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 40 | call SetupCommandAlias("git","Git") |
Skyler Grey | 6ad0c6d | 2022-08-10 09:54:25 +0100 | [diff] [blame] | 41 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 42 | let g:camelcasemotion_key = '<leader>' |
Skyler Grey | 60fcac9 | 2022-08-10 08:21:42 +0100 | [diff] [blame] | 43 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 44 | if exists('+termguicolors') |
Skyler Grey | a949ffd | 2022-06-23 23:32:48 +0100 | [diff] [blame] | 45 | let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" |
| 46 | let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" |
| 47 | set termguicolors |
Skyler Grey | 8d2f105 | 2022-07-09 21:02:17 +0100 | [diff] [blame] | 48 | endif |
Skyler Grey | 8d2f105 | 2022-07-09 21:02:17 +0100 | [diff] [blame] | 49 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 50 | 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 Grey | 849ee15 | 2022-08-12 13:30:07 +0100 | [diff] [blame^] | 58 | let g:airline#extensions#tabline#enabled = 1 |
| 59 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 60 | 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 Grey | 686ca7f | 2022-06-24 14:30:05 +0100 | [diff] [blame] | 111 | require('neorg').setup { |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 112 | load = { |
| 113 | ["core.defaults"] = {} |
| 114 | } |
Skyler Grey | 686ca7f | 2022-06-24 14:30:05 +0100 | [diff] [blame] | 115 | } |
Skyler Grey | 5510953 | 2022-07-04 18:31:29 +0100 | [diff] [blame] | 116 | |
Skyler Grey | b328357 | 2022-06-24 21:25:29 +0100 | [diff] [blame] | 117 | require('orgmode').setup_ts_grammar() |
Skyler Grey | 810c00e | 2022-06-24 21:16:22 +0100 | [diff] [blame] | 118 | |
| 119 | require('nvim-treesitter.configs').setup { |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 120 | highlight = { |
| 121 | enable = true, |
| 122 | additional_vim_regex_highlighting = {'org'}, |
Skyler Grey | 4597d65 | 2022-08-03 00:23:19 +0100 | [diff] [blame] | 123 | }, |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 124 | 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 Grey | 810c00e | 2022-06-24 21:16:22 +0100 | [diff] [blame] | 141 | } |
Skyler Grey | c0a5245 | 2022-07-09 21:06:53 +0100 | [diff] [blame] | 142 | |
| 143 | require('git-conflict').setup() |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 144 | EOF |
Skyler Grey | 4597d65 | 2022-08-03 00:23:19 +0100 | [diff] [blame] | 145 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 146 | set foldmethod=expr |
| 147 | set foldexpr=nvim_treesitter#foldexpr() |
Skyler Grey | 36eef4e | 2022-08-03 00:37:44 +0100 | [diff] [blame] | 148 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 149 | set viewoptions-=options |
| 150 | autocmd BufWinLeave ?* mkview! |
| 151 | autocmd BufWinEnter ?* normal zR |
Skyler Grey | dfd501b | 2022-08-11 09:48:47 +0100 | [diff] [blame] | 152 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 153 | function! s:loadViewOrUnfold() |
Skyler Grey | dfd501b | 2022-08-11 09:48:47 +0100 | [diff] [blame] | 154 | try |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 155 | loadview |
Skyler Grey | dfd501b | 2022-08-11 09:48:47 +0100 | [diff] [blame] | 156 | catch |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 157 | folddoclosed foldopen |
Skyler Grey | dfd501b | 2022-08-11 09:48:47 +0100 | [diff] [blame] | 158 | endtry |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 159 | endfunction |
Skyler Grey | dfd501b | 2022-08-11 09:48:47 +0100 | [diff] [blame] | 160 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 161 | autocmd BufWinEnter ?* call s:loadViewOrUnfold() |
| 162 | ''; |
Skyler Grey | 686ca7f | 2022-06-24 14:30:05 +0100 | [diff] [blame] | 163 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 164 | 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 Grey | 849ee15 | 2022-08-12 13:30:07 +0100 | [diff] [blame^] | 188 | pkgs.vimPlugins.airline |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 189 | (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars)) |
| 190 | ]; |
| 191 | }; |
Skyler Grey | c96cd8a | 2022-06-15 12:28:27 +0100 | [diff] [blame] | 192 | |
Skyler Grey | 49c030f | 2022-08-12 11:48:56 +0100 | [diff] [blame] | 193 | home.sessionVariables.EDITOR = "${pkgs.neovim}/bin/nvim"; |
Skyler Grey | 73c55fc | 2022-06-12 09:18:59 +0100 | [diff] [blame] | 194 | } |