LSP settings
This commit is contained in:
parent
4c1857384f
commit
d904e8654b
1 changed files with 23 additions and 2 deletions
|
@ -29,20 +29,41 @@ require('packer').startup(function(use)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Automatic LSP Setup
|
-- Automatic LSP Setup
|
||||||
|
local lspconf = {
|
||||||
|
sumneko_lua = {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { 'vim' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
local lspconfig = require('lspconfig')
|
local lspconfig = require('lspconfig')
|
||||||
require('mason').setup()
|
require('mason').setup()
|
||||||
require('mason-lspconfig').setup_handlers({
|
require('mason-lspconfig').setup_handlers({
|
||||||
function(server_name)
|
function(server_name)
|
||||||
lspconfig[server_name].setup {}
|
local opts = lspconf[server_name]
|
||||||
|
if opts == nil then
|
||||||
|
opts = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
lspconfig[server_name].setup(opts)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Format on save
|
-- Format on save
|
||||||
|
local function format_on_save()
|
||||||
|
vim.lsp.buf.formatting_sync()
|
||||||
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd(
|
vim.api.nvim_create_autocmd(
|
||||||
"BufWritePre",
|
"BufWritePre",
|
||||||
{
|
{
|
||||||
pattern = { "<buffer>" },
|
pattern = { "<buffer>" },
|
||||||
callback = vim.lsp.buf.formatting_sync,
|
callback = format_on_save,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue