local nvim_lsp = require('nvim_lsp') local nvim_status = require('lsp-status') local completion = require('completion') local status = require('tj.lsp_status') -- Can set this lower if needed. -- require('vim.lsp.log').set_level("debug") -- require('vim.lsp.log').set_level("trace") local mapper = function(mode, key, result) vim.api.nvim_buf_set_keymap(0, mode, key, result, {noremap = true, silent = true}) end local setup_custom_diagnostics = function() Diagnostic = require('vim.lsp.actions').Diagnostic Location = require('vim.lsp.actions').Location vim.lsp.callbacks["textDocument/publishDiagnostics"] = Diagnostic.handle_publish_diagnostics.with { should_underline = false, update_in_insert = false } mapper( 'n', 'dn', 'lua vim.lsp.structures.Diagnostic.buf_move_next_diagnostic()' ) mapper( 'n', 'dp', 'lua vim.lsp.structures.Diagnostic.buf_move_prev_diagnostic()' ) end -- Turn on status. status.activate() local custom_attach = function(client) completion.on_attach(client) status .on_attach(client) if false then pcall(setup_custom_diagnostics) end -- mapper('n', 'gd', 'lua vim.lsp.buf.declaration()') mapper('n', '', 'lua vim.lsp.buf.definition()') mapper('n', 'gD', 'lua vim.lsp.buf.implementation()') mapper('n', '1gD', 'lua vim.lsp.buf.type_definition()') mapper('n', 'gr', 'lua vim.lsp.buf.references()') mapper('n', 'ca', 'lua vim.lsp.buf.code_action()') mapper('n', 'cr', 'lua vim.lsp.buf.rename()') -- if not vim.api.nvim_buf_get_keymap(0, 'n')['K'] then if vim.api.nvim_buf_get_option(0, 'filetype') ~= 'lua' then mapper('n', 'K', 'lua vim.lsp.buf.hover()') end mapper('n', 'sl', 'lua vim.lsp.util.show_line_diagnostics()') mapper( 'n', 'gd', 'lua vim.lsp.buf.definition { callbacks = { Location.jump_first, Location.highlight.with { timeout = 300 } } }' ) mapper( 'n', 'pd', 'lua vim.lsp.buf.definition { callbacks = Location.preview.with { lines_below = 5 } }' ) -- Rust is currently the only thing w/ inlay hints if vim.api.nvim_buf_get_option(0, 'filetype') == 'rust' then vim.cmd [[autocmd BufEnter,BufWritePost :lua require('lsp_extensions.inlay_hints').request { aligned = true, prefix = " ยป " }]] end mapper('i', '', 'lua vim.lsp.buf.signature_help()') vim.cmd("setlocal omnifunc=v:lua.vim.lsp.omnifunc") end nvim_lsp.pyls.setup({ enable = true, plugins = { pyls_mypy = { enabled = true, live_mode = false } }, on_attach = custom_attach }) nvim_lsp.vimls.setup({ on_attach = custom_attach, }) -- Load lua configuration from nlua. require('nlua.lsp.nvim').setup(nvim_lsp, { on_attach = custom_attach, globals = { -- Colorbuddy "Color", "c", "Group", "g", "s", -- Custom "RELOAD", } }) if true then nvim_lsp.tsserver.setup({ cmd = {"typescript-language-server", "--stdio"}, filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }, on_attach = custom_attach }) else nvim_lsp.sourcegraph_ts.setup { on_attach = custom_attach } end nvim_lsp.clangd.setup({ cmd = {"clangd", "--background-index"}, on_attach = custom_attach, -- Required for lsp-status init_options = { clangdFileStatus = true }, callbacks = nvim_status.extensions.clangd.setup(), capabilities = nvim_status.capabilities, }) nvim_lsp.rust_analyzer.setup({ cmd = {"rust-analyzer"}, filetypes = {"rust"}, on_attach = custom_attach, }) --[[ Example settings, have not messed around with too many of these. -- require 'nvim_lsp'.pyls_ms.setup{ -- init_options = { -- interpreter = { -- properties = { -- InterpreterPath = "~/.pyenv/versions/sourceress/bin/python", -- Version = "3.6" -- } -- } -- } -- } let settings = { \ "pyls" : { \ "enable" : v:true, \ "trace" : { "server" : "verbose", }, \ "commandPath" : "", \ "configurationSources" : [ "pycodestyle" ], \ "plugins" : { \ "jedi_completion" : { "enabled" : v:true, }, \ "jedi_hover" : { "enabled" : v:true, }, \ "jedi_references" : { "enabled" : v:true, }, \ "jedi_signature_help" : { "enabled" : v:true, }, \ "jedi_symbols" : { \ "enabled" : v:true, \ "all_scopes" : v:true, \ }, \ "mccabe" : { \ "enabled" : v:true, \ "threshold" : 15, \ }, \ "preload" : { "enabled" : v:true, }, \ "pycodestyle" : { "enabled" : v:true, }, \ "pydocstyle" : { \ "enabled" : v:false, \ "match" : "(?!test_).*\\.py", \ "matchDir" : "[^\\.].*", \ }, \ "pyflakes" : { "enabled" : v:true, }, \ "rope_completion" : { "enabled" : v:true, }, \ "yapf" : { "enabled" : v:true, }, \ }}} --]]