fix(lsp): only run attach handler for related clients
This commit is contained in:
@@ -2,6 +2,11 @@ local util = require("util")
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client or client.name ~= "bashls" then
|
||||
return
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lf", function()
|
||||
util.format({
|
||||
buf = ev.buf,
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
local Linter = require("linter")
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client or client.name ~= "clangd" then
|
||||
return
|
||||
end
|
||||
|
||||
Linter.add(ev.buf, {
|
||||
cmd = {
|
||||
"clang-tidy",
|
||||
"-p=build/debug",
|
||||
"--quiet",
|
||||
"%file%",
|
||||
},
|
||||
events = { "BufWritePost" },
|
||||
clear_events = { "TextChanged", "TextChangedI" },
|
||||
stdin = false,
|
||||
stdout = true,
|
||||
pattern = "^.+:(%d+):(%d+): (%w+): (.*) %[(.*)%]$",
|
||||
groups = { "lnum", "col", "severity", "message", "code" },
|
||||
source = "clang-tidy",
|
||||
severity_map = {
|
||||
error = vim.diagnostic.severity.ERROR,
|
||||
warning = vim.diagnostic.severity.WARN,
|
||||
note = vim.diagnostic.severity.HINT,
|
||||
},
|
||||
zero_idx_col = true,
|
||||
zero_idx_lnum = true,
|
||||
ignore_stderr = true,
|
||||
})
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"gs",
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
local util = require("util")
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local util = require("util")
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client or client.name ~= "emmylua_ls" then
|
||||
return
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lf", function()
|
||||
util.format({
|
||||
|
||||
@@ -2,6 +2,11 @@ local util = require("util")
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client or client.name ~= "gopls" then
|
||||
return
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lf", function()
|
||||
util.format({
|
||||
buf = ev.buf,
|
||||
|
||||
@@ -3,6 +3,11 @@ local util = require("util")
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client or client.name ~= "intelephense" then
|
||||
return
|
||||
end
|
||||
|
||||
Linter.add(ev.buf, {
|
||||
cmd = {
|
||||
"phpcs",
|
||||
|
||||
+2
-1
@@ -62,9 +62,10 @@ end
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client then
|
||||
if not client or client.name ~= "jdtls" then
|
||||
return
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lf", function()
|
||||
format(client, ev.buf)
|
||||
end, { buffer = ev.buf })
|
||||
|
||||
@@ -2,6 +2,11 @@ local util = require("util")
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client or client.name ~= "ruff" then
|
||||
return
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lf", function()
|
||||
vim.lsp.buf.format()
|
||||
util.format({
|
||||
|
||||
Reference in New Issue
Block a user