diff --git a/nvim/coc-settings.json b/nvim/coc-settings.json deleted file mode 100644 index 88c92f7..0000000 --- a/nvim/coc-settings.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "git.addedSign.text": "▐", - "git.changedSign.text": "▐", - "git.removedSign.text": "▐", - "git.topRemovedSign.text": "▐", - "git.changeRemovedSign.text": "▐", - "suggest.noselect": false, - "diagnostic.errorSign": "✘", - "diagnostic.warningSign": "⚠", - "diagnostic.infoSign": "🛈", - "diagnostic.checkCurrentLine": true, - "diagnostic-languageserver.filetypes": { - "sh": "shellcheck" - }, - "diagnostic-languageserver.formatFiletypes": { - "sh": "shfmt" - }, - "coc.preferences.formatOnSaveFiletypes": [ - "css", - "go", - "html", - "javascript", - "json", - "ruby", - "rust", - "scss" - ], - "hover.target": "float", - "languageserver": { - "golang": { - "command": "gopls", - "rootPatterns": [ - "go.mod", - ".vim/", - ".git/", - ".hg/" - ], - "filetypes": [ - "go" - ], - "initializationOptions": { - "usePlaceholders": true - } - } - }, - "go.goplsOptions": { - "staticcheck": true - }, - "snippets.textmateSnippetsRoots": [ - "~/.config/coc/snippets" - ], - "rust-analyzer.checkOnSave.command": "clippy", - "solargraph.folding": true -} diff --git a/nvim/coc.vimrc b/nvim/coc.vimrc deleted file mode 100644 index a6cd67a..0000000 --- a/nvim/coc.vimrc +++ /dev/null @@ -1,162 +0,0 @@ -" Use tab for trigger completion with characters ahead and navigate. -" NOTE: Use command ':verbose imap ' to make sure tab is not mapped by -" other plugin before putting this into your config. -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -inoremap - \ pumvisible() ? "\" : - \ coc#expandableOrJumpable() ? - \ "\=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\" : - \ check_back_space() ? "\" : - \ coc#refresh() -inoremap pumvisible() ? "\" : "\" - -" Use to trigger completion. -if has('nvim') - inoremap coc#refresh() -else - inoremap coc#refresh() -endif - -let g:coc_snippet_next = '' -let g:coc_snippet_prev= '' - -" Make auto-select the first completion item and notify coc.nvim to -" format on enter, could be remapped by other vim plugin -inoremap pumvisible() ? coc#_select_confirm() - \: "\u\\=coc#on_enter()\" - -" Use `[g` and `]g` to navigate diagnostics -" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) - -" GoTo code navigation. -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('') - elseif (coc#rpc#ready()) - call CocActionAsync('doHover') - else - execute '!' . &keywordprg . " " . expand('') - endif -endfunction - -" Highlight the symbol and its references when holding the cursor. -autocmd CursorHold * silent call CocActionAsync('highlight') - -" Symbol renaming. -nmap rn (coc-rename) - -" Formatting selected code. -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 - -" Applying codeAction to the selected region. -" Example: `aap` for current paragraph -xmap a (coc-codeaction-selected) -nmap a (coc-codeaction-selected) - -" Remap keys for applying codeAction to the current buffer. -nmap ac (coc-codeaction) -" Apply AutoFix to problem on the current line. -nmap qf (coc-fix-current) - -" Map function and class text objects -" NOTE: Requires 'textDocument.documentSymbol' support from the language server. -xmap if (coc-funcobj-i) -omap if (coc-funcobj-i) -xmap af (coc-funcobj-a) -omap af (coc-funcobj-a) -xmap ic (coc-classobj-i) -omap ic (coc-classobj-i) -xmap ac (coc-classobj-a) -omap ac (coc-classobj-a) - -" Remap and for scroll float windows/popups. -if has('nvim-0.4.0') || has('patch-8.2.0750') - nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" -endif - -" Use CTRL-S for selections ranges. -" Requires 'textDocument/selectionRange' support of language server. -nmap (coc-range-select) -xmap (coc-range-select) - -" Add `:Format` command to format current buffer. -command! -nargs=0 Format :call CocAction('format') - -" Add `:Fold` command to fold current buffer. -"command! -nargs=? Fold :call CocAction('fold', ) - -" Add `:OR` command for organize imports of the current buffer. -command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - -" Add (Neo)Vim's native statusline support. -" NOTE: Please see `:h coc-status` for integrations with external plugins that -" provide custom statusline: lightline.vim, vim-airline. -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} - -" Mappings for 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 - -" CoC-Git mappings -" navigate chunks of current buffer -nmap [h (coc-git-prevchunk) -nmap ]h (coc-git-nextchunk) -" navigate conflicts of current buffer -nmap [c (coc-git-prevconflict) -nmap ]c (coc-git-nextconflict) -" show chunk diff at current position -nmap gs (coc-git-chunkinfo) -" show commit contains current position -nmap gc (coc-git-commit) -" create text object for git chunks -omap ig (coc-git-chunk-inner) -xmap ig (coc-git-chunk-inner) -omap ag (coc-git-chunk-outer) -xmap ag (coc-git-chunk-outer) -" undo current chunk -nmap hu :CocCommand git.chunkUndo -nmap hs :CocCommand git.chunkStage -" git list -nnoremap g :CocList --normal gstatus diff --git a/nvim/lspconfig.vimrc b/nvim/lspconfig.vimrc new file mode 100644 index 0000000..c18b14b --- /dev/null +++ b/nvim/lspconfig.vimrc @@ -0,0 +1,48 @@ +lua << EOF +local nvim_lsp = require('lspconfig') + +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +local on_attach = function(client, bufnr) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + + -- Enable completion triggered by + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + + -- See `:help vim.lsp.*` for documentation on any of the below functions + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) + +end + +-- Use a loop to conveniently call 'setup' on multiple servers and +-- map buffer local keybindings when the language server attaches +local servers = { 'solargraph', 'rust_analyzer', 'gopls', 'tsserver' } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, + } + } +end +EOF diff --git a/nvim/nvimtree.vimrc b/nvim/nvimtree.vimrc index 695a283..ffb62e3 100644 --- a/nvim/nvimtree.vimrc +++ b/nvim/nvimtree.vimrc @@ -29,3 +29,5 @@ let g:nvim_tree_icons = { \ } noremap :NvimTreeToggle + +lua require 'nvim-tree'.setup{} diff --git a/nvim/plugins.vimrc b/nvim/plugins.vimrc index 5fb824d..e08550e 100644 --- a/nvim/plugins.vimrc +++ b/nvim/plugins.vimrc @@ -5,6 +5,7 @@ Plug 'jiangmiao/auto-pairs' Plug 'leafgarland/typescript-vim', { 'for': 'typescript' } Plug 'leafoftree/vim-svelte-plugin', { 'for': 'svelte' } Plug 'lukas-reineke/indent-blankline.nvim' +Plug 'neovim/nvim-lspconfig' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'posva/vim-vue', { 'for': 'vue' } Plug 'ron-rs/ron.vim', { 'for': 'ron' } @@ -17,10 +18,6 @@ Plug 'tpope/vim-surround' Plug 'vim-test/vim-test' Plug 'wakatime/vim-wakatime' -" CoC -Plug 'neoclide/coc.nvim', {'branch': 'release'} | - \ Plug 'neoclide/coc-git' - " Lightline Plug 'itchyny/lightline.vim' | \ Plug 'albertomontesg/lightline-asyncrun' | @@ -39,11 +36,6 @@ Plug 'kyazdani42/nvim-tree.lua' | Plug 'godlygeek/tabular' | \ Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } -" Telescope -Plug 'nvim-lua/popup.nvim' -Plug 'nvim-lua/plenary.nvim' -Plug 'nvim-telescope/telescope.nvim' - " sonokai colorscheme + supporting plugins Plug 'sainnhe/sonokai' | \ Plug 'rmolin88/pomodoro.vim' | diff --git a/nvim/telescope.vimrc b/nvim/telescope.vimrc deleted file mode 100644 index 82baac8..0000000 --- a/nvim/telescope.vimrc +++ /dev/null @@ -1,53 +0,0 @@ -nnoremap ff Telescope find_files -nnoremap fg Telescope live_grep -nnoremap fG Telescope git_files -nnoremap fb Telescope buffers -nnoremap fh Telescope help_tags -nnoremap fw Telescope grep_string - -lua << EOF -require('telescope').setup{ - defaults = { - vimgrep_arguments = { - 'rg', - '--color=never', - '--no-heading', - '--with-filename', - '--line-number', - '--column', - '--smart-case' - }, - prompt_prefix = " 🔍 ", - selection_caret = " ⯈ ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "descending", - layout_strategy = "horizontal", - layout_config = { - horizontal = { - mirror = false, - }, - vertical = { - mirror = false, - }, - }, - file_sorter = require'telescope.sorters'.get_fuzzy_file, - file_ignore_patterns = {}, - generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter, - winblend = 0, - border = {}, - borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' }, - color_devicons = true, - use_less = true, - path_display = {}, - set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil, - file_previewer = require'telescope.previewers'.vim_buffer_cat.new, - grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, - qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new, - - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker - } -} -EOF diff --git a/vimrc b/vimrc index 1d2ad5a..22ba83f 100644 --- a/vimrc +++ b/vimrc @@ -68,16 +68,15 @@ if filereadable(expand("~/.config/nvim/plugins.vimrc")) endif call plug#end() +if filereadable(expand("~/.config/nvim/lspconfig.vimrc")) + source ~/.config/nvim/lspconfig.vimrc +endif + " Keybindings if filereadable(expand("~/.config/nvim/keybindings.vimrc")) source ~/.config/nvim/keybindings.vimrc endif -" CoC -if filereadable(expand("~/.config/nvim/coc.vimrc")) - source ~/.config/nvim/coc.vimrc -endif - " Lightline setup if filereadable(expand("~/.config/nvim/lightline.vimrc")) source ~/.config/nvim/lightline.vimrc @@ -108,11 +107,6 @@ if filereadable(expand("~/.config/nvim/projections.vimrc")) source ~/.config/nvim/projections.vimrc endif -" Telescope setup -if filereadable(expand("~/.config/nvim/telescope.vimrc")) - source ~/.config/nvim/telescope.vimrc -endif - " Test setup if filereadable(expand("~/.config/nvim/test.vimrc")) source ~/.config/nvim/test.vimrc