[nvim] spacing and html lsp and formatting fixes
This commit is contained in:
parent
ef323b4c7f
commit
87e6a4d0c4
|
@ -1,195 +1,212 @@
|
||||||
return {
|
return {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
"creativenull/efmls-configs-nvim",
|
"creativenull/efmls-configs-nvim",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
local lspwindow = require("lspconfig.ui.windows")
|
local lspwindow = require("lspconfig.ui.windows")
|
||||||
|
|
||||||
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
|
||||||
-- disable showing diagnostics in virtual text
|
-- disable showing diagnostics in virtual text
|
||||||
vim.diagnostic.config({ virtual_text = false })
|
vim.diagnostic.config({ virtual_text = false })
|
||||||
|
|
||||||
-- close quickfix menu after selecting choice
|
-- close quickfix menu after selecting choice
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
pattern = { "qf" },
|
pattern = { "qf" },
|
||||||
command = [[nnoremap <buffer> <CR> <CR>:cclose<CR>]],
|
command = [[nnoremap <buffer> <CR> <CR>:cclose<CR>]],
|
||||||
})
|
})
|
||||||
|
|
||||||
-- override all window borders
|
-- override all window borders
|
||||||
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
||||||
local border = "rounded"
|
local border = "rounded"
|
||||||
|
|
||||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
opts.border = border
|
opts.border = border
|
||||||
return orig_util_open_floating_preview(contents, syntax, opts, ...)
|
return orig_util_open_floating_preview(contents, syntax, opts, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lspinfo needs a separate override
|
-- lspinfo needs a separate override
|
||||||
lspwindow.default_options = {
|
lspwindow.default_options = {
|
||||||
border = border,
|
border = border,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- LSP settings (for overriding per client)
|
-- LSP settings (for overriding per client)
|
||||||
local handlers = {}
|
local handlers = {}
|
||||||
|
|
||||||
local on_attach = function(_, bufnr)
|
local on_attach = function(_, bufnr)
|
||||||
-- Mappings.
|
-- Mappings.
|
||||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||||
|
|
||||||
-- See `:help vim.lsp.*` for more methods
|
-- See `:help vim.lsp.*` for more methods
|
||||||
vim.keymap.set("n", "<leader>bf", function()
|
vim.keymap.set("n", "<leader>bf", function()
|
||||||
vim.lsp.buf.format({ timeout = 2000, async = true })
|
vim.lsp.buf.format({ timeout = 2000, async = true })
|
||||||
end, bufopts)
|
end, bufopts)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function organize_imports()
|
local function organize_imports()
|
||||||
local params = {
|
local params = {
|
||||||
command = "_typescript.organizeImports",
|
command = "_typescript.organizeImports",
|
||||||
arguments = { vim.api.nvim_buf_get_name(0) },
|
arguments = { vim.api.nvim_buf_get_name(0) },
|
||||||
title = "",
|
title = "",
|
||||||
}
|
}
|
||||||
vim.lsp.buf.execute_command(params)
|
vim.lsp.buf.execute_command(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
local servers = {
|
local servers = {
|
||||||
{
|
{
|
||||||
"tsserver",
|
"tsserver",
|
||||||
commands = {
|
commands = {
|
||||||
LspOrganizeImports = {
|
LspOrganizeImports = {
|
||||||
organize_imports,
|
organize_imports,
|
||||||
description = "Organize Imports",
|
description = "Organize Imports",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ "tailwindcss" },
|
{ "tailwindcss" },
|
||||||
{ "graphql" },
|
{ "graphql" },
|
||||||
{ "html" },
|
{ "intelephense" },
|
||||||
{ "intelephense" },
|
{ "jsonls" },
|
||||||
{ "jsonls" },
|
{ "pyright" },
|
||||||
{ "pyright" },
|
{ "vimls" },
|
||||||
{ "vimls" },
|
{ "bashls" },
|
||||||
{ "bashls" },
|
{ "dockerls" },
|
||||||
{ "dockerls" },
|
{ "solargraph" },
|
||||||
{ "solargraph" },
|
-- { "rubocop" }, -- needs rubocop >= 1.54
|
||||||
-- { "rubocop" }, -- needs rubocop >= 1.54
|
-- { "ruby_ls" }, -- wait for nvim 0.10
|
||||||
-- { "ruby_ls" }, -- wait for nvim 0.10
|
{ "gopls", {
|
||||||
{ "gopls", {
|
root_dir = function()
|
||||||
root_dir = function()
|
return vim.loop.cwd()
|
||||||
return vim.loop.cwd()
|
end,
|
||||||
end,
|
} },
|
||||||
} },
|
{ "eslint" },
|
||||||
{ "eslint" },
|
{
|
||||||
{
|
"yamlls",
|
||||||
"yamlls",
|
settings = {
|
||||||
settings = {
|
yaml = {
|
||||||
yaml = {
|
schemas = {
|
||||||
schemas = {
|
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
|
||||||
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
|
["https://raw.githubusercontent.com/woodpecker-ci/woodpecker/master/pipeline/schema/schema.json"] = "/.woodpecker",
|
||||||
["https://raw.githubusercontent.com/woodpecker-ci/woodpecker/master/pipeline/schema/schema.json"] = "/.woodpecker",
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
{ "stylelint_lsp" },
|
||||||
{ "stylelint_lsp" },
|
{
|
||||||
{ "cssls" },
|
"html",
|
||||||
{
|
settings = {
|
||||||
"efm",
|
html = {
|
||||||
filetypes = {
|
hover = {
|
||||||
"lua",
|
documentation = true,
|
||||||
"fish",
|
references = true,
|
||||||
"ruby",
|
},
|
||||||
"javascript",
|
},
|
||||||
"typescript",
|
css = {
|
||||||
"javascriptreact",
|
validate = true,
|
||||||
"typescriptreact",
|
},
|
||||||
"javascript.tsx",
|
},
|
||||||
"typescript.tsx"
|
},
|
||||||
},
|
{ "cssls" },
|
||||||
init_options = {
|
{
|
||||||
documentFormatting = true,
|
"efm",
|
||||||
hover = true,
|
filetypes = {
|
||||||
documentSymbol = true,
|
"lua",
|
||||||
codeAction = true,
|
"fish",
|
||||||
completion = true,
|
"ruby",
|
||||||
},
|
"html",
|
||||||
settings = {
|
"javascript",
|
||||||
rootMarkers = { ".git/" },
|
"typescript",
|
||||||
languages = {
|
"javascriptreact",
|
||||||
lua = {
|
"typescriptreact",
|
||||||
require("efmls-configs.linters.luacheck"),
|
"javascript.tsx",
|
||||||
},
|
"typescript.tsx"
|
||||||
fish = {
|
},
|
||||||
require("efmls-configs.linters.fish"),
|
init_options = {
|
||||||
require("efmls-configs.formatters.fish_indent"),
|
documentFormatting = true,
|
||||||
},
|
hover = true,
|
||||||
ruby = {
|
documentSymbol = true,
|
||||||
require("efmls-configs.linters.rubocop"),
|
codeAction = true,
|
||||||
},
|
completion = true,
|
||||||
javascript = {
|
},
|
||||||
require("efmls-configs.formatters.prettier"),
|
settings = {
|
||||||
},
|
rootMarkers = { ".git/" },
|
||||||
typescript = {
|
languages = {
|
||||||
require("efmls-configs.formatters.prettier"),
|
lua = {
|
||||||
},
|
require("efmls-configs.linters.luacheck"),
|
||||||
javascriptreact = {
|
},
|
||||||
require("efmls-configs.formatters.prettier"),
|
fish = {
|
||||||
},
|
require("efmls-configs.linters.fish"),
|
||||||
typescriptreact = {
|
require("efmls-configs.formatters.fish_indent"),
|
||||||
require("efmls-configs.formatters.prettier"),
|
},
|
||||||
},
|
html = {
|
||||||
["javascript.tsx"] = {
|
require("efmls-configs.formatters.prettier"),
|
||||||
require("efmls-configs.formatters.prettier"),
|
},
|
||||||
},
|
ruby = {
|
||||||
["typescript.tsx"] = {
|
require("efmls-configs.linters.rubocop"),
|
||||||
require("efmls-configs.formatters.prettier"),
|
},
|
||||||
},
|
javascript = {
|
||||||
},
|
require("efmls-configs.formatters.prettier"),
|
||||||
},
|
},
|
||||||
},
|
typescript = {
|
||||||
{
|
require("efmls-configs.formatters.prettier"),
|
||||||
"lua_ls",
|
},
|
||||||
settings = {
|
javascriptreact = {
|
||||||
Lua = {
|
require("efmls-configs.formatters.prettier"),
|
||||||
runtime = {
|
},
|
||||||
version = 'LuaJIT',
|
typescriptreact = {
|
||||||
},
|
require("efmls-configs.formatters.prettier"),
|
||||||
diagnostics = {
|
},
|
||||||
globals = { 'vim' },
|
["javascript.tsx"] = {
|
||||||
},
|
require("efmls-configs.formatters.prettier"),
|
||||||
workspace = {
|
},
|
||||||
library = vim.api.nvim_get_runtime_file("", true),
|
["typescript.tsx"] = {
|
||||||
},
|
require("efmls-configs.formatters.prettier"),
|
||||||
telemetry = {
|
},
|
||||||
enable = false,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
},
|
"lua_ls",
|
||||||
}
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
version = 'LuaJIT',
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
globals = { 'vim' },
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
library = vim.api.nvim_get_runtime_file("", true),
|
||||||
|
},
|
||||||
|
telemetry = {
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
for _, server in pairs(servers) do
|
for _, server in pairs(servers) do
|
||||||
local config = lspconfig[server[1]]
|
local config = lspconfig[server[1]]
|
||||||
local setup_config = {
|
local setup_config = {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
handlers = handlers,
|
handlers = handlers,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Add custom config if available
|
-- Add custom config if available
|
||||||
for k, v in pairs(server) do
|
for k, v in pairs(server) do
|
||||||
if type(k) ~= "number" then
|
if type(k) ~= "number" then
|
||||||
setup_config[k] = v
|
setup_config[k] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.setup(setup_config)
|
config.setup(setup_config)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue