You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.1 KiB
100 lines
2.1 KiB
-- Learn the keybindings, see :help lsp-zero-keybindings
|
|
-- Learn to configure LSP servers, see :help lsp-zero-api-showcase
|
|
local lsp = require('lsp-zero')
|
|
lsp.preset('recommended')
|
|
|
|
lsp.setup_nvim_cmp({
|
|
experimental = {
|
|
ghost_text = true,
|
|
},
|
|
})
|
|
|
|
-- (Optional) Configure lua language server for neovim
|
|
lsp.nvim_workspace()
|
|
|
|
local servers = {
|
|
'tailwindcss',
|
|
'tsserver',
|
|
'texlab',
|
|
'pyright',
|
|
'ltex',
|
|
'jsonls'
|
|
}
|
|
|
|
lsp.ensure_installed(servers)
|
|
|
|
lsp.configure("tsserver", {
|
|
on_init = function(client)
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
client.server_capabilities.documentFormattingRangeProvider = false
|
|
end
|
|
})
|
|
|
|
lsp.on_attach(function(client, bufnr)
|
|
local opts = { buffer = bufnr, remap = false }
|
|
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
|
vim.keymap.set("n", "<leader>rn", function() vim.lsp.buf.rename() end, opts)
|
|
end)
|
|
|
|
|
|
lsp.setup()
|
|
|
|
vim.diagnostic.config({
|
|
virtual_text = true,
|
|
underline = true,
|
|
float = true,
|
|
})
|
|
|
|
local null_ls = require('null-ls')
|
|
local null_opts = lsp.build_options('null-ls', {})
|
|
|
|
null_ls.setup({
|
|
on_attach = function(client, bufnr)
|
|
null_opts.on_attach(client, bufnr)
|
|
|
|
local format_cmd = function(input)
|
|
vim.lsp.buf.format({
|
|
id = client.id,
|
|
timeout_ms = 5000,
|
|
async = input.bang,
|
|
})
|
|
end
|
|
|
|
local bufcmd = vim.api.nvim_buf_create_user_command
|
|
bufcmd(bufnr, 'NullFormat', format_cmd, {
|
|
bang = true,
|
|
range = true,
|
|
desc = 'Format using null-ls'
|
|
})
|
|
end,
|
|
sources = {
|
|
}
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
pattern = { "*.go", "*.py", "*.lua", "*.rs" },
|
|
callback = function(args)
|
|
vim.lsp.buf.format {
|
|
timeout_ms = 5000
|
|
}
|
|
end
|
|
})
|
|
|
|
vim.keymap.set("n", "<leader>ft", function()
|
|
vim.lsp.buf.format()
|
|
end)
|
|
|
|
require('mason').setup()
|
|
require("mason-nvim-dap").setup({
|
|
automatic_setup = true,
|
|
})
|
|
require 'mason-nvim-dap'.setup_handlers {}
|
|
|
|
|
|
require('mason-null-ls').setup({
|
|
ensure_installed = { "autopep8", "eslint", "gofmt", "rustfmt", "shellcheck" },
|
|
automatic_installation = true,
|
|
automatic_setup = true,
|
|
})
|
|
|
|
require('mason-null-ls').setup_handlers()
|