summary refs log tree commit diff
path: root/.vim/lua/plugins/_lsp.lua
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2021-07-29 23:39:08 +0200
committerRobert Günzler <r@gnzler.io>2021-07-29 23:40:32 +0200
commit3079e935c793a9aa1831fd165e28636eb7a87dae (patch)
treee832ac6a08ad70c14c01b1eac32ac1b5eec3549f /.vim/lua/plugins/_lsp.lua
parentcefbce656c511a3583744ed7735aa71249b73500 (diff)
vim: cleanup config
Diffstat (limited to '')
-rw-r--r--.vim/lua/plugins/_lsp.lua176
1 files changed, 0 insertions, 176 deletions
diff --git a/.vim/lua/plugins/_lsp.lua b/.vim/lua/plugins/_lsp.lua
deleted file mode 100644
index 39a10b9..0000000
--- a/.vim/lua/plugins/_lsp.lua
+++ /dev/null
@@ -1,176 +0,0 @@
--- lsp config
-
-local lsp      = require('lspconfig')
-local util     = require('lspconfig.util')
-local u        = require('utils')
-local nnoremap = require('astronauta.keymap').nnoremap
-
-local M = {}
-local my_attach = function(client)
-  -- attach completion
-  require 'completion'.on_attach(client)
-
-  -- lsp mappings
-  nnoremap { 'K'         , vim.lsp.buf.hover }
-  nnoremap { '<C-]>'     , vim.lsp.buf.definition }
-  nnoremap { 'gd'        , vim.lsp.buf.definition }
-  nnoremap { 'grr'       , vim.lsp.buf.rename }
-  nnoremap { '<c-h>'     , vim.lsp.buf.signature_help }
-  nnoremap { ']d'        , vim.lsp.diagnostic.goto_next }
-  nnoremap { '[d'        , vim.lsp.diagnostic.goto_prev }
-
-  nnoremap { '<leader>f' , vim.lsp.buf.formatting }
-  -- nnoremap { 'g0', vim.lsp.buf.document_symbol }
-  nnoremap { 'gR'        , vim.lsp.buf.references }
-  nnoremap { 'gW'        , vim.lsp.buf.workspace_symbol }
-  nnoremap { 'gD'        , vim.lsp.buf.declaration }
-  nnoremap { 'gT'        , vim.lsp.buf.type_definition }
-  nnoremap { 'gI'        , vim.lsp.buf.implementation }
-
-  -- nnoremap <silent> ;s <cmd> lua vim.lsp.buf.signature_help()<CR>
-  nnoremap { '<leader>d' , vim.lsp.diagnostic.show_line_diagnostics }
-
-  u.augroup2 {
-    lsp_user = {
-      {'BufWritePre' , '*'    ,  'lua vim.lsp.buf.formatting_sync(nil, 1000)'},
-      {'BufWritePre' , '*.go' ,  'lua vim.lsp.buf.code_action({ source = { organizeImports = true } })'},
-      -- {'CursorHold'  , '*'    ,  'lua vim.lsp.diagnostic.show_line_diagnostics()'},
-    }
-  }
-end
-
--- handler overwrites
--- configure builtin diagnositcs
-vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( -- {{{
-  vim.lsp.diagnostic.on_publish_diagnostics, {
-    virtual_text     = false,
-    signs            = true,
-    underline        = true,
-    update_in_insert = false,
-  }
-)
--- }}}
-
--- overwrite codeAction handler to not ask for confirmation if only a single
--- action is given
-vim.lsp.handlers["textDocument/codeAction"] = function(_, _, actions) -- {{{
-  if actions == nil or vim.tbl_isempty(actions) then
-    -- skip printing 'no code actions available'
-    return
-  end
-
-  local action_cosen
-  if #actions == 1 then
-    action_chosen = actions[1]
-  else
-    local option_strings = {"Code Actions:"}
-    for i, action in ipairs(actions) do
-      local title = action.title:gsub('\r\n', '\\r\\n')
-      title = title:gsub('\n', '\\n')
-      table.insert(option_strings, string.format("%d. %s", i, title))
-    end
-
-    local choice = vim.fn.inputlist(option_strings)
-    if choice < 1 or choice > #actions then
-      return
-    end
-    action_chosen = actions[choice]
-  end
-
-  if action_chosen.edit or type(action_chosen.command) == "table" then
-    if action_chosen.edit then
-      vim.lsp.util.apply_workspace_edit(action_chosen.edit)
-    end
-    if type(action_chosen.command) == "table" then
-      vim.lsp.buf.execute_command(action_chosen.command)
-    end
-  else
-    vim.lsp.buf.execute_command(action_chosen)
-  end
-end
--- }}}
-
--- configure signs {{{
-vim.fn.sign_define("LspDiagnosticsSignError", {text="⚡", numhl="Error"})
-vim.fn.sign_define("LspDiagnosticsSignWarning", {text="⯈", numhl="Warning"})
-vim.fn.sign_define("LspDiagnosticsSignInformation", {text="≈"})
-vim.fn.sign_define("LspDiagnosticsSignHint", {text="🞶"})
--- }}}
-
--- lsp.ccls.setup{
---  on_attach = my_attach,
--- }
-
-lsp.gopls.setup{
-  on_attach = my_attach,
-  -- root_dir = util.root_pattern('go.mod', '.git'),
-  settings = {
-    gopls = {
-      -- analyses = {
-      --  composites = false
-      -- },
-      codelenses = {
-        test = true,
-        tidy = true,
-      },
-      gofumpt = true,
-    }
-  }
-}
-
-lsp.sumneko_lua.setup{
-  on_attach = my_attach;
-  cmd = { 'lua-language-server' };
-  settings = {
-    Lua = {
-      runtime = {
-        version = 'LuaJIT',
-      },
-      diagnostics = {
-        globals = {'vim'},
-      },
-      workspace = {
-        library = {
-          [vim.fn.expand('$VIMRUNTIME/lua')] = true,
-          [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true,
-        }
-      }
-    }
-  }
-}
-
-lsp.rust_analyzer.setup{
-  on_attach = my_attach,
-  cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'rust-analyzer' },
-}
-
-lsp.efm.setup{
-  on_attach = my_attach,
-  root_dir = util.root_pattern('.git', '.editorconfig'),
-  init_options = { documentFormatting = true },
-  -- filetypes = { "sh", "c" },
-  settings = {
-    -- rootMarkers = {".git/"},
-    languages = {
-      sh = {
-        {
-          lintCommand = 'shellcheck -f gcc -x',
-          lintSource = 'shellcheck',
-          lintFormats = {
-            '%f:%l:%c: %trror: %m',
-            '%f:%l:%c: %tarning: %m',
-            '%f:%l:%c: %tote: %m',
-          },
-          formatCommand = 'shfmt -ci -s -bn',
-          formatStdin = true,
-        }
-      }
-    }
-  }
-}
-
-lsp.zls.setup{
-  on_attach = my_attach
-}
-
-return M