From 18791ed12a7aa1053c9a91f8d27050ef349e8071 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 29 Oct 2022 02:25:11 +0200 Subject: [PATCH] Cleanup nvim config --- home/neovim/init.lua | 58 ++- home/neovim/init.vim | 89 +++++ home/neovim/neovim.nix | 863 +++++++++++++++++++++-------------------- 3 files changed, 567 insertions(+), 443 deletions(-) create mode 100644 home/neovim/init.vim diff --git a/home/neovim/init.lua b/home/neovim/init.lua index 16bb610..72f9bb3 100644 --- a/home/neovim/init.lua +++ b/home/neovim/init.lua @@ -1,20 +1,44 @@ --- init.lua +require('packer').startup(function(use) + use { "williamboman/mason.nvim" } --- Load custom tree-sitter grammar for org filetype -require('orgmode').setup_ts_grammar() + use { + 'VonHeikemen/lsp-zero.nvim', + requires = { + -- LSP Support + { 'neovim/nvim-lspconfig' }, + { 'williamboman/mason.nvim' }, + { 'williamboman/mason-lspconfig.nvim' }, --- Tree-sitter configuration -require'nvim-treesitter.configs'.setup { - -- If TS highlights are not enabled at all, or disabled via `disable` prop, highlighting will fallback to default Vim syntax highlighting - highlight = { - enable = true, - disable = {'org'}, -- Remove this to use TS highlighter for some of the highlights (Experimental) - additional_vim_regex_highlighting = {'org'}, -- Required since TS highlighter doesn't support all syntax features (conceal) - }, - ensure_installed = {'org'}, -- Or run :TSUpdate org -} + -- Autocompletion + { 'hrsh7th/nvim-cmp' }, + { 'hrsh7th/cmp-buffer' }, + { 'hrsh7th/cmp-path' }, + { 'saadparwaiz1/cmp_luasnip' }, + { 'hrsh7th/cmp-nvim-lsp' }, + { 'hrsh7th/cmp-nvim-lua' }, -require('orgmode').setup({ - org_agenda_files = {'~/Nextcloud/org/*'}, - org_default_notes_file = '~/Nextcloud/org/refile.org', -}) + -- Snippets + { 'L3MON4D3/LuaSnip' }, + { 'rafamadriz/friendly-snippets' }, + } + } + + use { + 'nvim-treesitter/nvim-treesitter', + run = function() require('nvim-treesitter.install').update({ with_sync = true }) end, + } + + use { 'kien/ctrlp.vim' } + + use { 'tpope/vim-commentary' } + use { 'tpope/vim-surround' } + + use { 'vim-scripts/lastpos.vim' } +end) + +local lsp = require('lsp-zero') + +lsp.preset('recommended') +lsp.setup() + +require('nvim-treesitter.configs').setup{highlight={enable=true}} diff --git a/home/neovim/init.vim b/home/neovim/init.vim new file mode 100644 index 0000000..f588b97 --- /dev/null +++ b/home/neovim/init.vim @@ -0,0 +1,89 @@ +set number +set relativenumber + +set expandtab +set shiftwidth=2 +set tabstop=2 + +set ignorecase +set smartcase + +" always set autoindenting on +set autoindent +" smart indent; stop indent when closing brackets etc +set smartindent + +" highlight search result +set hlsearch +" incremental search +set incsearch + +" yank into system clipboard +set clipboard=unnamedplus + +" true color +set termguicolors + +" other color for popup +highlight Pmenu ctermbg=gray guibg=gray + +set signcolumn=yes + +" break at last word instead of last char +set linebreak + +set cursorline + +" autoload file changes +set autoread + +set smarttab + +set shiftround + +" invisible characters +set list + +" keep 5 lines on the screen when scrolling +set scrolloff=5 +" enhanced command line completion +set wildmenu +" Search down into subfolders +" Provides tab-completion for all file-related tasks +set path+=** + +" show incomplete commands +set showcmd + +" complete files like a shell +set wildmode=list:longest + +" set spell langs +set spelllang=de,en + +" persist undo history +set undofile + +" clear highlighted search +noremap :nohlsearch + +" Highlight symbol under cursor on CursorHold +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Append modeline after last line in buffer. +" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX files. +function! AppendModeline() + let l:modeline = printf(" vim: set filetype=%s ts=%d sw=%d tw=%d %s :", + \ &filetype, &tabstop, &shiftwidth, &textwidth, &expandtab ? 'et' : 'noet') + let l:modeline = substitute(&commentstring, "%s", l:modeline, "") + call append(line("$"), l:modeline) +endfunction +nnoremap ml :call AppendModeline() + +syntax enable + +if executable('rg') + set grepprg=rg\ --color=never + let g:ctrlp_user_command='rg %s --files -i --color=never --glob ""' + let g:ctrlp_use_caching=0 +endif diff --git a/home/neovim/neovim.nix b/home/neovim/neovim.nix index fea0c4e..b45c694 100644 --- a/home/neovim/neovim.nix +++ b/home/neovim/neovim.nix @@ -2,436 +2,447 @@ let config = { plugins = with pkgs.vimPlugins; [ - vim-colors-solarized + packer-nvim + # vim-colors-solarized - coc-nvim - coc-rust-analyzer - coc-pyright - coc-go + # coc-nvim + # coc-rust-analyzer + # coc-pyright + # coc-go - # orgmode-nvim - # nvim-treesitter + # # orgmode-nvim + # # nvim-treesitter - ctrlp-vim - editorconfig-vim - vim-gist - goyo-vim - # gopls - neomake - rust-vim - solarized - vim-commentary - vim-dispatch - vim-fugitive - vim-gitgutter - vim-lastplace - vim-nix - vim-polyglot - vim-repeat - # vim-scala - vim-sleuth - vim-surround - vim-trailing-whitespace - # vimtex - vimux - vimwiki + # ctrlp-vim + # editorconfig-vim + # vim-gist + # goyo-vim + # # gopls + # neomake + # rust-vim + # solarized + # vim-commentary + # vim-dispatch + # vim-fugitive + # vim-gitgutter + # vim-lastplace + # vim-nix + # vim-polyglot + # vim-repeat + # # vim-scala + # vim-sleuth + # vim-surround + # vim-trailing-whitespace + # # vimtex + # vimux + # vimwiki ]; enable = true; - extraConfig = '' - set background=dark - " allow switching away from unsaved buffers - set hidden - set history=1000 - - set updatetime=300 - - set expandtab - set shiftwidth=2 - set tabstop=2 - - set ignorecase - set smartcase - - set number - set relativenumber - - set backupdir=$HOME/.vim/backupfiles// - set directory=$HOME/.vim/swapfiles// - set undodir=$HOME/.vim/undofiles// - set undofile - - set nocompatible - - filetype plugin indent on - - " always set autoindenting on - set autoindent - " smart indent; stop indent when closing brackets etc - set smartindent - " two spaces after .?! when joining lines - set joinspaces - - " highlight search result - set hlsearch - " incremental search - set incsearch - set nolazyredraw - - " delete whitespace, line break and char using - set backspace=indent,eol,start - " always show curser position - set ruler - - " yank into system clipboard - set clipboard=unnamedplus - - colorscheme solarized - " true color - set termguicolors - " make true colors work in tmux - let &t_8f = "\[38;2;%lu;%lu;%lum" - let &t_8b = "\[48;2;%lu;%lu;%lum" - - " set textwidth=80 - set colorcolumn=+1 - set signcolumn=yes - " highlight current line - set cursorline - - " encoding - set fileencoding=utf-8 - - " break at last word instead of last char - set linebreak - - " autoload file changes - set autoread - - set smarttab - - set softtabstop=2 - set shiftround - - " invisible characters - set list - " set listchars=tab:â\ ,eol:¬,trail:â,extends:â¯,precedes:â® - " set showbreak=⪠- - " code folding settings - " fold based on syntax - set foldmethod=indent - " don't fold by default - set nofoldenable - set foldlevel=1 - - " smoother redrawing - set ttyfast - " diff with vertical split - set diffopt+=vertical - " show the status line all the time - set laststatus=2 - " keep 5 lines on the screen when scrolling - set scrolloff=5 - " enhanced command line completion - set wildmenu - " Search down into subfolders - " Provides tab-completion for all file-related tasks - set path+=** - - " show incomplete commands - set showcmd - - " complete files like a shell - set wildmode=list:longest - - " command bar height - set cmdheight=1 - " set terminal title - set title - " set shortmess+=TOFwatc - set shortmess+=c - - " show matching braces - set showmatch - " how many tenths of a second to blink - set mat=2 - " set spell langs - set spelllang=de,en - - syntax enable - " let g:polyglot_disabled=['latex'] - " highlight clear SpellBad - " highlight SpellBad cterm=undercurl - - " " Only do this part when compiled with support for autocommands. - " if has("autocmd") - " " Put these in an autocmd group, so that we can delete them easily. - " augroup vimrcEx - " au! - " autocmd FileType text setlocal foldtext< - " augroup END - " endif " has("autocmd") - - " error bells - set errorbells - set visualbell - set timeoutlen=500 - - " turn on manpages (:Man) - runtime ftplugin/man.vim - - " set a map leader for more key combos - let mapleader=',' - - " clear highlighted search - noremap :nohlsearch - - " enable . command in visual mode - vnoremap . :normal . - - " make the highlighting of tabs and other non-text less annoying - highlight SpecialKey ctermbg=none ctermfg=8 - highlight NonText ctermbg=none ctermfg=8 - - " other color for popup - highlight Pmenu ctermbg=gray guibg=gray - - " ctrlp - " order top to bottom - let g:ctrlp_match_window='bottom,order::ttb' - " open files in new buffer - let g:ctrlp_switch_buffer=0 - " use ripgrep if available - if executable('rg') - set grepprg=rg\ --color=never - let g:ctrlp_user_command='rg %s --files -i --color=never --glob ""' - let g:ctrlp_use_caching=0 - endif - - " set textwidth for mails - autocmd FileType mail setlocal textwidth=72 - - " count wraped lines as one line when doing relative jumps - noremap j (v:count == 0 ? 'gj' : 'j') - noremap k (v:count == 0 ? 'gk' : 'k') - - " scroll the viewport faster - nnoremap 3 - nnoremap 3 - - "" Section AutoGroups {{{ - "" file type specific settings - augroup configgroup - autocmd! - - " automatically resize panes on resize - autocmd VimResized * exe 'normal! \=' - autocmd BufWritePost .vimrc,.vimrc.local,init.vim source % - " save all files on focus lost, ignoring warnings about untitled buffers - autocmd FocusLost * silent! wa - - " make quickfix windows take all the lower section of the screen - " when there are multiple windows open - autocmd FileType qf wincmd J - - autocmd! BufWritePost * Neomake - augroup END - " }}} - - " Append modeline after last line in buffer. - " Use substitute() instead of printf() to handle '%%s' modeline in LaTeX files. - function! AppendModeline() - let l:modeline = printf(" vim: set filetype=%s ts=%d sw=%d tw=%d %s :", - \ &filetype, &tabstop, &shiftwidth, &textwidth, &expandtab ? 'et' : 'noet') - let l:modeline = substitute(&commentstring, "%s", l:modeline, "") - call append(line("$"), l:modeline) - endfunction - nnoremap ml :call AppendModeline() - - " netrw settings - " disable banner - let g:netrw_banner=0 - " open in prior window - let g:netrw_browse_split=4 - " open splits to the right - let g:netrw_altv=1 - " treeview - let g:netrw_liststyle=3 - let g:netrw_list_hide=netrw_gitignore#Hide() - let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' - - " vimux mappings - " Prompt for a command - map vp :VimuxPromptCommand - " Prompt for a make command - map vm :VimuxPromptCommand("make ") - " Inspect runner pane - map vi :VimuxInspectRunner - " Close runner - map vq :VimuxCloseRunner - " Rerun last command - map vv :VimuxRunLastCommand - " Stop running command - map vs :VimuxInterruptRunner - - " close Goyo *and* vim with :q - function! s:goyo_enter() - let b:quitting=0 - let b:quitting_bang=0 - autocmd QuitPre let b:quitting=1 - cabbrev q! let b:quitting_bang=1 q! - endfunction - - function! s:goyo_leave() - " Quit Vim if this is the only remaining buffer - if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 - if b:quitting_bang - qa! - else - qa - endif - endif - endfunction - autocmd! User GoyoEnter call goyo_enter() - autocmd! User GoyoLeave call goyo_leave() - - " run rustfmt when saving a file - let g:rustfmt_autosave=1 - - au BufRead,BufNewFile *.sbt set filetype=scala - - " textwidth for emails - au BufRead /tmp/*mutt-* set tw=72 - augroup filetypedetect - " Mail - autocmd BufRead,BufNewFile *mutt-* setfiletype mail - augroup END - - - let g:coc_global_extensions = [ - \ 'coc-explorer', - \ 'coc-snippets', - \ 'coc-pairs' - \ ] - nmap ge :CocCommand explorer - " Use tab for trigger completion with characters ahead and navigate. - " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. - inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() - inoremap pumvisible() ? "\" : "\" - - function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' - endfunction - - " Use to trigger completion. - inoremap coc#refresh() - - " Use to confirm completion, `u` means break undo chain at current position. - " Coc only does snippet and additional edit on confirm. - inoremap pumvisible() ? "\" : "\u\" - " Or use `complete_info` if your vim support it, like: - " inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" - - " Use `[g` and `]g` to navigate diagnostics - nmap [g (coc-diagnostic-prev) - nmap ]g (coc-diagnostic-next) - - " Remap keys for gotos - nmap gd (coc-definition) - nmap gy (coc-type-definition) - nmap gi (coc-implementation) - nmap gr (coc-references) - - " Use K to show documentation in preview window - nnoremap K :call show_documentation() - - function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - endif - endfunction - - " Highlight symbol under cursor on CursorHold - autocmd CursorHold * silent call CocActionAsync('highlight') - - " Remap for rename current word - nmap rn (coc-rename) - - " Remap for format selected region - xmap f (coc-format-selected) - nmap f (coc-format-selected) - - augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') - augroup end - - " Remap for do codeAction of selected region, ex: `aap` for current paragraph - xmap a (coc-codeaction-selected) - nmap a (coc-codeaction-selected) - - " Remap for do codeAction of current line - nmap ac (coc-codeaction) - " Fix autofix problem of current line - nmap qf (coc-fix-current) - - " Create mappings for function text object, requires document symbols feature of languageserver. - xmap if (coc-funcobj-i) - xmap af (coc-funcobj-a) - omap if (coc-funcobj-i) - omap af (coc-funcobj-a) - - " Use for select selections ranges, needs server support, like: coc-tsserver, coc-python - nmap (coc-range-select) - xmap (coc-range-select) - - " Use `:Format` to format current buffer - command! -nargs=0 Format :call CocAction('format') - - " Use `:Fold` to fold current buffer - command! -nargs=? Fold :call CocAction('fold', ) - - " use `:OR` for organize import of current buffer - command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - - " Add status line support, for integration with other plugin, checkout `:h coc-status` - " set statusline^=%{coc#status()}%{get(b:,'coc_current_function',''')} - - " Using CocList - " Show all diagnostics - nnoremap a :CocList diagnostics - " Manage extensions - nnoremap e :CocList extensions - " Show commands - nnoremap c :CocList commands - " Find symbol of current document - nnoremap o :CocList outline - " Search workspace symbols - nnoremap s :CocList -I symbols - " Do default action for next item. - nnoremap j :CocNext - " Do default action for previous item. - nnoremap k :CocPrev - " Resume latest coc list - nnoremap p :CocListResume - - " properly find root for py projects in workspace - autocmd FileType python let b:coc_root_patterns = ['.git', '.env', 'venv', '.venv', 'setup.cfg', 'setup.py', 'pyproject.toml', 'pyrightconfig.json'] - - " let g:tex_flavor = 'latex' - ''; + # extraConfig = '' + # set background=dark + # " allow switching away from unsaved buffers + # set hidden + # set history=1000 + + # set updatetime=300 + + # set expandtab + # set shiftwidth=2 + # set tabstop=2 + + # set ignorecase + # set smartcase + + # set number + # set relativenumber + + # set backupdir=$HOME/.vim/backupfiles// + # set directory=$HOME/.vim/swapfiles// + # set undodir=$HOME/.vim/undofiles// + # set undofile + + # set nocompatible + + # filetype plugin indent on + + # " always set autoindenting on + # set autoindent + # " smart indent; stop indent when closing brackets etc + # set smartindent + # " two spaces after .?! when joining lines + # set joinspaces + + # " highlight search result + # set hlsearch + # " incremental search + # set incsearch + # set nolazyredraw + + # " delete whitespace, line break and char using + # set backspace=indent,eol,start + # " always show curser position + # set ruler + + # " yank into system clipboard + # set clipboard=unnamedplus + + # colorscheme solarized + # " true color + # set termguicolors + # " make true colors work in tmux + # let &t_8f = "\[38;2;%lu;%lu;%lum" + # let &t_8b = "\[48;2;%lu;%lu;%lum" + + # " set textwidth=80 + # set colorcolumn=+1 + # set signcolumn=yes + # " highlight current line + # set cursorline + + # " encoding + # set fileencoding=utf-8 + + # " break at last word instead of last char + # set linebreak + + # " autoload file changes + # set autoread + + # set smarttab + + # set softtabstop=2 + # set shiftround + + # " invisible characters + # set list + # " set listchars=tab:â\ ,eol:¬,trail:â,extends:â¯,precedes:â® + # " set showbreak=⪠+ + # " code folding settings + # " fold based on syntax + # set foldmethod=indent + # " don't fold by default + # set nofoldenable + # set foldlevel=1 + + # " smoother redrawing + # set ttyfast + # " diff with vertical split + # set diffopt+=vertical + # " show the status line all the time + # set laststatus=2 + # " keep 5 lines on the screen when scrolling + # set scrolloff=5 + # " enhanced command line completion + # set wildmenu + # " Search down into subfolders + # " Provides tab-completion for all file-related tasks + # set path+=** + + # " show incomplete commands + # set showcmd + + # " complete files like a shell + # set wildmode=list:longest + + # " command bar height + # set cmdheight=1 + # " set terminal title + # set title + # " set shortmess+=TOFwatc + # set shortmess+=c + + # " show matching braces + # set showmatch + # " how many tenths of a second to blink + # set mat=2 + # " set spell langs + # set spelllang=de,en + + # syntax enable + # " let g:polyglot_disabled=['latex'] + # " highlight clear SpellBad + # " highlight SpellBad cterm=undercurl + + # " " Only do this part when compiled with support for autocommands. + # " if has("autocmd") + # " " Put these in an autocmd group, so that we can delete them easily. + # " augroup vimrcEx + # " au! + # " autocmd FileType text setlocal foldtext< + # " augroup END + # " endif " has("autocmd") + + # " error bells + # set errorbells + # set visualbell + # set timeoutlen=500 + + # " turn on manpages (:Man) + # runtime ftplugin/man.vim + + # " set a map leader for more key combos + # let mapleader=',' + + # " clear highlighted search + # noremap :nohlsearch + + # " enable . command in visual mode + # vnoremap . :normal . + + # " make the highlighting of tabs and other non-text less annoying + # highlight SpecialKey ctermbg=none ctermfg=8 + # highlight NonText ctermbg=none ctermfg=8 + + # " other color for popup + # highlight Pmenu ctermbg=gray guibg=gray + + # " ctrlp + # " order top to bottom + # let g:ctrlp_match_window='bottom,order::ttb' + # " open files in new buffer + # let g:ctrlp_switch_buffer=0 + # " use ripgrep if available + # if executable('rg') + # set grepprg=rg\ --color=never + # let g:ctrlp_user_command='rg %s --files -i --color=never --glob ""' + # let g:ctrlp_use_caching=0 + # endif + + # " set textwidth for mails + # autocmd FileType mail setlocal textwidth=72 + + # " count wraped lines as one line when doing relative jumps + # noremap j (v:count == 0 ? 'gj' : 'j') + # noremap k (v:count == 0 ? 'gk' : 'k') + + # " scroll the viewport faster + # nnoremap 3 + # nnoremap 3 + + # "" Section AutoGroups {{{ + # "" file type specific settings + # augroup configgroup + # autocmd! + + # " automatically resize panes on resize + # autocmd VimResized * exe 'normal! \=' + # autocmd BufWritePost .vimrc,.vimrc.local,init.vim source % + # " save all files on focus lost, ignoring warnings about untitled buffers + # autocmd FocusLost * silent! wa + + # " make quickfix windows take all the lower section of the screen + # " when there are multiple windows open + # autocmd FileType qf wincmd J + + # autocmd! BufWritePost * Neomake + # augroup END + # " }}} + + # " Append modeline after last line in buffer. + # " Use substitute() instead of printf() to handle '%%s' modeline in LaTeX files. + # function! AppendModeline() + # let l:modeline = printf(" vim: set filetype=%s ts=%d sw=%d tw=%d %s :", + # \ &filetype, &tabstop, &shiftwidth, &textwidth, &expandtab ? 'et' : 'noet') + # let l:modeline = substitute(&commentstring, "%s", l:modeline, "") + # call append(line("$"), l:modeline) + # endfunction + # nnoremap ml :call AppendModeline() + + # " netrw settings + # " disable banner + # let g:netrw_banner=0 + # " open in prior window + # let g:netrw_browse_split=4 + # " open splits to the right + # let g:netrw_altv=1 + # " treeview + # let g:netrw_liststyle=3 + # let g:netrw_list_hide=netrw_gitignore#Hide() + # let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' + + # " vimux mappings + # " Prompt for a command + # map vp :VimuxPromptCommand + # " Prompt for a make command + # map vm :VimuxPromptCommand("make ") + # " Inspect runner pane + # map vi :VimuxInspectRunner + # " Close runner + # map vq :VimuxCloseRunner + # " Rerun last command + # map vv :VimuxRunLastCommand + # " Stop running command + # map vs :VimuxInterruptRunner + + # " close Goyo *and* vim with :q + # function! s:goyo_enter() + # let b:quitting=0 + # let b:quitting_bang=0 + # autocmd QuitPre let b:quitting=1 + # cabbrev q! let b:quitting_bang=1 q! + # endfunction + + # function! s:goyo_leave() + # " Quit Vim if this is the only remaining buffer + # if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 + # if b:quitting_bang + # qa! + # else + # qa + # endif + # endif + # endfunction + # autocmd! User GoyoEnter call goyo_enter() + # autocmd! User GoyoLeave call goyo_leave() + + # " run rustfmt when saving a file + # let g:rustfmt_autosave=1 + + # au BufRead,BufNewFile *.sbt set filetype=scala + + # " textwidth for emails + # au BufRead /tmp/*mutt-* set tw=72 + # augroup filetypedetect + # " Mail + # autocmd BufRead,BufNewFile *mutt-* setfiletype mail + # augroup END + + + # let g:coc_global_extensions = [ + # \ 'coc-explorer', + # \ 'coc-snippets', + # \ 'coc-pairs' + # \ ] + # nmap ge :CocCommand explorer + # " Use tab for trigger completion with characters ahead and navigate. + # " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. + # inoremap + # \ pumvisible() ? "\" : + # \ check_back_space() ? "\" : + # \ coc#refresh() + # inoremap pumvisible() ? "\" : "\" + + # function! s:check_back_space() abort + # let col = col('.') - 1 + # return !col || getline('.')[col - 1] =~# '\s' + # endfunction + + # " Use to trigger completion. + # inoremap coc#refresh() + + # " Use to confirm completion, `u` means break undo chain at current position. + # " Coc only does snippet and additional edit on confirm. + # inoremap pumvisible() ? "\" : "\u\" + # " Or use `complete_info` if your vim support it, like: + # " inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" + + # " Use `[g` and `]g` to navigate diagnostics + # nmap [g (coc-diagnostic-prev) + # nmap ]g (coc-diagnostic-next) + + # " Remap keys for gotos + # nmap gd (coc-definition) + # nmap gy (coc-type-definition) + # nmap gi (coc-implementation) + # nmap gr (coc-references) + + # " Use K to show documentation in preview window + # nnoremap K :call show_documentation() + + # function! s:show_documentation() + # if (index(['vim','help'], &filetype) >= 0) + # execute 'h '.expand('') + # else + # call CocAction('doHover') + # endif + # endfunction + + # " Highlight symbol under cursor on CursorHold + # autocmd CursorHold * silent call CocActionAsync('highlight') + + # " Remap for rename current word + # nmap rn (coc-rename) + + # " Remap for format selected region + # xmap f (coc-format-selected) + # nmap f (coc-format-selected) + + # augroup mygroup + # autocmd! + # " Setup formatexpr specified filetype(s). + # autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + # " Update signature help on jump placeholder + # autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') + # augroup end + + # " Remap for do codeAction of selected region, ex: `aap` for current paragraph + # xmap a (coc-codeaction-selected) + # nmap a (coc-codeaction-selected) + + # " Remap for do codeAction of current line + # nmap ac (coc-codeaction) + # " Fix autofix problem of current line + # nmap qf (coc-fix-current) + + # " Create mappings for function text object, requires document symbols feature of languageserver. + # xmap if (coc-funcobj-i) + # xmap af (coc-funcobj-a) + # omap if (coc-funcobj-i) + # omap af (coc-funcobj-a) + + # " Use for select selections ranges, needs server support, like: coc-tsserver, coc-python + # nmap (coc-range-select) + # xmap (coc-range-select) + + # " Use `:Format` to format current buffer + # command! -nargs=0 Format :call CocAction('format') + + # " Use `:Fold` to fold current buffer + # command! -nargs=? Fold :call CocAction('fold', ) + + # " use `:OR` for organize import of current buffer + # command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + + # " Add status line support, for integration with other plugin, checkout `:h coc-status` + # " set statusline^=%{coc#status()}%{get(b:,'coc_current_function',''')} + + # " Using CocList + # " Show all diagnostics + # nnoremap a :CocList diagnostics + # " Manage extensions + # nnoremap e :CocList extensions + # " Show commands + # nnoremap c :CocList commands + # " Find symbol of current document + # nnoremap o :CocList outline + # " Search workspace symbols + # nnoremap s :CocList -I symbols + # " Do default action for next item. + # nnoremap j :CocNext + # " Do default action for previous item. + # nnoremap k :CocPrev + # " Resume latest coc list + # nnoremap p :CocListResume + + # " properly find root for py projects in workspace + # autocmd FileType python let b:coc_root_patterns = ['.git', '.env', 'venv', '.venv', 'setup.cfg', 'setup.py', 'pyproject.toml', 'pyrightconfig.json'] + + # " let g:tex_flavor = 'latex' + # ''; # lua << EOF # ${builtins.readFile ./init.lua} # EOF + # generatedConfigs = { + # lua = builtins.readFile ./plugins.lua; + # }; + extraConfig = '' + ${builtins.readFile ./init.vim} + + lua << EOF + ${builtins.readFile ./init.lua} + EOF + ''; }; in { # Note that this doesn’t merge deeply, so you couldn’t add to plugins. For that @@ -443,10 +454,10 @@ in { viAlias = true; coc = { enable = true; - settings = { - "rust-analyzer.serverPath" = "${pkgs.rust-analyzer}/bin/rust-analyzer"; - "gopls.experimentalWorkspaceModule" = true; - }; + # settings = { + # "rust-analyzer.serverPath" = "${pkgs.rust-analyzer}/bin/rust-analyzer"; + # "gopls.experimentalWorkspaceModule" = true; + # }; }; } // config; # programs.vim = config;