74 lines
2.1 KiB
Lua
74 lines
2.1 KiB
Lua
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua
|
|
local runtime_path = vim.split(package.path, ";")
|
|
table.insert(runtime_path, "lua/?.lua")
|
|
table.insert(runtime_path, "lua/?/init.lua")
|
|
|
|
local opts = {
|
|
settings = {
|
|
Lua = {
|
|
runtime = {
|
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
version = "LuaJIT",
|
|
-- Setup your lua path
|
|
path = runtime_path,
|
|
},
|
|
diagnostics = {
|
|
-- Get the language server to recognize the `vim` global
|
|
globals = { "vim" },
|
|
},
|
|
workspace = {
|
|
-- Make the server aware of Neovim runtime files
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
checkThirdParty = false,
|
|
},
|
|
-- Do not send telemetry data containing a randomized but unique identifier
|
|
telemetry = {
|
|
enable = false,
|
|
},
|
|
},
|
|
},
|
|
flags = {
|
|
debounce_text_changes = 150,
|
|
},
|
|
on_attach = function(client, bufnr)
|
|
-- 禁用格式化功能,交给专门插件插件处理
|
|
client.server_capabilities.document_formatting = false
|
|
client.server_capabilities.document_range_formatting = false
|
|
|
|
vim.api.nvim_create_autocmd("CursorHold", {
|
|
buffer = bufnr,
|
|
callback = function()
|
|
local opts = {
|
|
focusable = false,
|
|
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
|
border = "rounded",
|
|
source = "always",
|
|
prefix = " ",
|
|
scope = "cursor",
|
|
}
|
|
vim.diagnostic.open_float(nil, opts)
|
|
end,
|
|
})
|
|
local function buf_set_keymap(...)
|
|
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
|
end
|
|
require("keybindings").maplsp(buf_set_keymap)
|
|
end,
|
|
-- -- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
|
-- -- 绑定快捷键
|
|
}
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
|
opts.capabilities = capabilities
|
|
|
|
-- 查看目录等信息
|
|
-- print(vim.inspect(server))
|
|
|
|
return {
|
|
on_setup = function(server)
|
|
-- opts = require("lua-dev").setup({ lspconfig = opts })
|
|
server.setup(opts)
|
|
end,
|
|
}
|