From 095b5798f240ed533a1c4f0432f5b8c943c734d7 Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Thu, 4 Nov 2021 12:38:12 -0700 Subject: [PATCH] attempt to use gopls only --- .vim/filetype.vim | 4 ++-- .vim/nvim.lua | 65 +++++++++++++++++++++++++++++++++++-------------------- .vimrc | 4 +++- 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/.vim/filetype.vim b/.vim/filetype.vim index b858312..91444a0 100644 --- a/.vim/filetype.vim +++ b/.vim/filetype.vim @@ -93,8 +93,8 @@ augroup go autocmd FileType go set softtabstop=2 autocmd FileType go set shiftwidth=2 autocmd FileType go set noexpandtab - autocmd FileType go nmap gd (go-doc) - autocmd FileType go nmap gd (go-def) + "autocmd FileType go nmap gd (go-doc) + "autocmd FileType go nmap gd (go-def) augroup END augroup idris diff --git a/.vim/nvim.lua b/.vim/nvim.lua index d1cdacb..7f7c36c 100644 --- a/.vim/nvim.lua +++ b/.vim/nvim.lua @@ -11,6 +11,24 @@ nvim_lsp.gopls.setup({ on_attach=on_attach }) nvim_lsp.pyright.setup({ on_attach=on_attach }) nvim_lsp.clangd.setup({ on_attach=on_attach }) +function org_imports(wait_ms) + local params = vim.lsp.util.make_range_params() + + params.context = {only = {"source.organizeImports"}} + + local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, wait_ms) + + for _, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + vim.lsp.util.apply_workspace_edit(r.edit) + else + vim.lsp.buf.execute_command(r.command) + end + end + end +end + nvim_lsp.efm.setup { init_options = {documentFormatting = true}, settings = { @@ -115,7 +133,8 @@ vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) require('lspkind').init({ -- disables text annotations - with_text = false, + --with_text = false, + with_text = true, -- default symbol map -- can be either 'default' or 'codicons' @@ -123,28 +142,28 @@ require('lspkind').init({ -- override preset symbols -- default: {} - symbol_map = { - Method = 'm', - Function = 'f', - Text = 'txt', - Constructor = 'new', - Variable = 'var', - Class = 'cls', - Interface = 'iface', - Module = 'mod', - Property = 'prop', - Unit = 'unit', - Value = 'val', - Enum = 'enum', - Keyword = 'kw', - Snippet = 'sn', - Color = 'color', - File = 'file', - Folder = 'fold', - EnumMember = 'enum', - Constant = 'const', - Struct = 'struct', - }, + --symbol_map = { + --Method = 'm', + --Function = 'f', + --Text = 'txt', + --Constructor = 'new', + --Variable = 'var', + --Class = 'cls', + --Interface = 'iface', + --Module = 'mod', + --Property = 'prop', + --Unit = 'unit', + --Value = 'val', + --Enum = 'enum', + --Keyword = 'kw', + --Snippet = 'sn', + --Color = 'color', + --File = 'file', + --Folder = 'fold', + --EnumMember = 'enum', + --Constant = 'const', + --Struct = 'struct', + --}, }) require('trouble').setup { diff --git a/.vimrc b/.vimrc index 06d1989..9f2ae47 100644 --- a/.vimrc +++ b/.vimrc @@ -142,7 +142,7 @@ Plug 'airblade/vim-rooter' Plug 'majutsushi/tagbar' Plug 'SirVer/ultisnips' Plug 'honza/vim-snippets' -Plug 'fatih/vim-go' +"Plug 'fatih/vim-go' Plug 'jiangmiao/auto-pairs' Plug 'tpope/vim-abolish' Plug 'sheerun/vim-polyglot' @@ -317,6 +317,8 @@ autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics({show_header = autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 1000) autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 1000) autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_seq_sync(nil, 1000) +autocmd BufWritePre *.go lua vim.lsp.buf.formatting_seq_sync(nil, 1000) +autocmd BufWritePre *.go :silent! lua org_imports(3000) " Goto previous/next diagnostic warning/error nnoremap g[ lua vim.lsp.diagnostic.goto_prev()