109 lines
3.1 KiB
Nix
109 lines
3.1 KiB
Nix
{ pkgs, lib, inputs, config, ...}:
|
|
let
|
|
# fromGitHub = rev: ref: repo: pkgs.vimUtils.buildVimPluginFrom2Nix {
|
|
# pname = "${lib.strings.sanitizeDerivationName repo}";
|
|
# version = ref;
|
|
# src = builtins.fetchGit {
|
|
# url = "https://github.com/${repo}.git";
|
|
# ref = ref;
|
|
# rev = rev;
|
|
# };
|
|
# };
|
|
in {
|
|
programs.neovim = {
|
|
enable = true;
|
|
defaultEditor = true;
|
|
viAlias = true;
|
|
vimAlias = true;
|
|
vimdiffAlias = true;
|
|
plugins = with pkgs.vimPlugins; [
|
|
lightline-vim
|
|
vim-lightline-coc
|
|
|
|
vim-commentary
|
|
vim-fugitive
|
|
|
|
nerdtree
|
|
nerdtree-git-plugin
|
|
vim-devicons
|
|
|
|
nvim-lspconfig
|
|
copilot-vim
|
|
nvim-treesitter
|
|
|
|
coc-nvim
|
|
coc-pyright
|
|
|
|
vim-nix
|
|
];
|
|
|
|
extraConfig = ''
|
|
let mapleader = ','
|
|
|
|
" Integrate status with lightline
|
|
let g:lightline = {
|
|
\ 'active': {
|
|
\ 'left': [[ 'coc_info', 'coc_hints', 'coc_errors', 'coc_warnings', 'coc_ok' ], [ 'coc_status' ]]
|
|
\ }
|
|
\ }
|
|
|
|
" register components:
|
|
call lightline#coc#register()
|
|
|
|
" GoTo code navigation.
|
|
nmap <silent> gd <Plug>(coc-definition)
|
|
nmap <silent> gy <Plug>(coc-type-definition)
|
|
nmap <silent> gi <Plug>(coc-implementation)
|
|
nmap <silent> gr <Plug>(coc-references)
|
|
|
|
" Use K to show documentation in preview window.
|
|
nnoremap <silent> K :call ShowDocumentation()<CR>
|
|
function! ShowDocumentation()
|
|
if CocAction('hasProvider', 'hover')
|
|
call CocActionAsync('doHover')
|
|
else
|
|
call feedkeys('K', 'in')
|
|
endif
|
|
endfunction
|
|
|
|
" Enable syntax folding with coc
|
|
command! -nargs=* Fold :call CocAction('fold', <f-args>)
|
|
|
|
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
|
|
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
|
|
|
" Highlight the symbol and its references when holding the cursor.
|
|
autocmd CursorHold * silent call CocActionAsync('highlight')
|
|
|
|
" Symbol renaming.
|
|
nmap <leader>rn <Plug>(coc-rename)
|
|
|
|
" Use CTRL-S for selections ranges.
|
|
" Requires 'textDocument/selectionRange' support of language server.
|
|
nmap <silent> <C-s> <Plug>(coc-range-select)
|
|
xmap <silent> <C-s> <Plug>(coc-range-select)
|
|
|
|
" Step through diagnostics
|
|
nmap <silent> <g <Plug>(coc-diagnostic-prev)
|
|
nmap <silent> >g <Plug>(coc-diagnostic-next)
|
|
|
|
" Nerdtree-settings
|
|
" Toggle nerdtree on Ctrl+t
|
|
nmap <silent> <C-t> :NERDTreeToggle<CR>
|
|
autocmd VimEnter * NERDTree " Autostart nerdtree on vim startup
|
|
autocmd VimEnter * wincmd p " Unselect nerdtree window
|
|
" Close vim is Nerdtree is the only buffer left
|
|
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
|
|
|
" List and switch buffers on Ctrl+k
|
|
nnoremap <C-k> :set nomore <Bar> :ls <Bar> :set more <CR>:b<Space>
|
|
|
|
" Show trailing whitespace
|
|
highlight ExtraWhitespace ctermbg=red guibg=red
|
|
match ExtraWhitespace /\s\+$/
|
|
|
|
" Disable search highlights
|
|
map <Leader><Space> :noh<CR>
|
|
'';
|
|
};
|
|
} |