You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
navigator.lua/lua/navigator/lspclient/attach.lua

58 lines
1.6 KiB
Lua

4 years ago
local vim, api = vim, vim.api
local lsp = require("vim.lsp")
local util = require "navigator.util"
local log = util.log
local trace = util.trace
4 years ago
local diagnostic_map = function(bufnr)
local opts = {noremap = true, silent = true}
api.nvim_buf_set_keymap(bufnr, "n", "]O", ":lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
end
local M = {}
M.on_attach = function(client, bufnr)
log("attaching", bufnr, client.name)
trace(client)
local hassig, sig = pcall(require, "lsp_signature")
if hassig then
sig.on_attach()
end
4 years ago
diagnostic_map(bufnr)
-- lspsaga
require"navigator.lspclient.highlight".add_highlight()
4 years ago
api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
require("navigator.lspclient.mapping").setup({
client = client,
bufnr = bufnr,
cap = client.resolved_capabilities
})
4 years ago
if client.resolved_capabilities.document_highlight then
require("navigator.dochighlight").documentHighlight()
4 years ago
end
require"navigator.lspclient.lspkind".init()
4 years ago
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
local config = require"navigator".config_values()
trace(client.name, "navigator on attach")
if config.on_attach ~= nil then
trace(client.name, "general attach")
config.on_attach(client, bufnr)
end
if config.lsp and config.lsp[client.name] and config.lsp[client.name].on_attach ~= nil then
trace(client.name, "custom attach")
config.lsp[client.name].on_attach(client, bufnr)
end
4 years ago
end
M.setup = function(cfg)
return M
end
4 years ago
return M