mirror of
https://git.korhonen.cc/FunctionalHacker/dotfiles.git
synced 2024-11-18 21:27:42 +00:00
Fix scope issues in lspconfig
This commit is contained in:
parent
b985e8a28a
commit
0f738beb9b
@ -17,4 +17,4 @@ require('jdtls').start_or_attach({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
require('plugins.lspconfig').lsp_map_keys('jdtls', nil)
|
require('plugins.lspconfig').map_keys('jdtls', nil)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
require 'plugins/init'
|
|
||||||
require 'autocmd'
|
require 'autocmd'
|
||||||
require 'keybinds'
|
require 'keybinds'
|
||||||
require 'settings'
|
require 'settings'
|
||||||
require 'common'
|
require 'common'
|
||||||
|
require 'plugins/init'
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
local M = {}
|
M = {}
|
||||||
|
|
||||||
function lsp_map_keys(server, bufnr)
|
function M.map_keys(server, bufnr)
|
||||||
print('lsp_map_keys')
|
|
||||||
local function map_key(...)
|
local function map_key(...)
|
||||||
-- Map to buffer if buffer number is supplied,
|
-- Map to buffer if buffer number is supplied,
|
||||||
-- globally otherwise
|
-- globally otherwise
|
||||||
@ -42,62 +41,58 @@ function lsp_map_keys(server, bufnr)
|
|||||||
map_key('n', '<space>f', '<cmd>lua vim.lsp.buf.format()<CR>', keymapOpts)
|
map_key('n', '<space>f', '<cmd>lua vim.lsp.buf.format()<CR>', keymapOpts)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.on_attach = function(server, bufnr)
|
function M.setup()
|
||||||
print('on_attach')
|
-- Pairs of server name and settings.
|
||||||
|
-- This is iterated through and every
|
||||||
|
-- server is setup with lspconfig
|
||||||
|
local servers = {
|
||||||
|
html = {},
|
||||||
|
jsonls = {},
|
||||||
|
marksman = {},
|
||||||
|
yamlls = {},
|
||||||
|
tsserver = {},
|
||||||
|
sumneko_lua = {
|
||||||
|
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 = vim.split(package.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)
|
||||||
|
},
|
||||||
|
-- Do not send telemetry data containing a randomized but unique identifier
|
||||||
|
telemetry = {enable = false}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local function on_attach(server, bufnr)
|
||||||
-- Setup lsp signature plugin
|
-- Setup lsp signature plugin
|
||||||
require('lsp_signature').setup {}
|
require('lsp_signature').setup {}
|
||||||
|
|
||||||
-- Setup keybinds
|
-- Setup keybinds
|
||||||
lsp_map_keys(server, bufnr)
|
M.map_keys(server, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Setup every defined server
|
||||||
function M.setup()
|
for server, settings in pairs(servers) do
|
||||||
local lspconfig = require('lspconfig')
|
require('lspconfig')[server].setup {
|
||||||
|
on_attach = on_attach,
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
settings = settings,
|
||||||
|
-- Updates capabilities to cmp.nvim and
|
||||||
-- Common settings for all servers
|
-- informs the server about the client capabilities
|
||||||
local lsp_defaults = {
|
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp
|
||||||
on_attach = M.on_attach, -- Common on_attach
|
.protocol
|
||||||
capabilities = capabilities -- Add additional capabilities supported by nvim-cmp
|
.make_client_capabilities())
|
||||||
}
|
}
|
||||||
|
end
|
||||||
-- Set default config for all servers
|
|
||||||
--lspconfig.util.default_config = vim.tbl_deep_extend('force', lspconfig.util.default_config, lsp_defaults)
|
|
||||||
|
|
||||||
-- Register capabilities to cmp.nvim
|
|
||||||
--require('cmp_nvim_lsp').update_capabilities(capabilities)
|
|
||||||
|
|
||||||
-- LSP servers setup
|
|
||||||
--lspconfig.tsserver.setup {}
|
|
||||||
--lspconfig.yamlls.setup {}
|
|
||||||
--lspconfig.jsonls.setup {}
|
|
||||||
--lspconfig.html.setup {}
|
|
||||||
--lspconfig.marksman.setup {}
|
|
||||||
|
|
||||||
--lspconfig.sumneko_lua.setup {
|
|
||||||
-- 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 = vim.split(package.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)
|
|
||||||
-- },
|
|
||||||
-- -- Do not send telemetry data containing a randomized but unique identifier
|
|
||||||
-- telemetry = { enable = false }
|
|
||||||
-- }
|
|
||||||
-- }
|
|
||||||
--}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
Loading…
Reference in New Issue
Block a user