mirror of https://github.com/LazyVim/starter
feat(lsp): add custom diagnostics for 'really' usage
parent
95f9550202
commit
315f9f753b
2
init.lua
2
init.lua
|
@ -1,4 +1,2 @@
|
|||
-- bootstrap lazy.nvim, LazyVim and your plugins
|
||||
require("config.lazy")
|
||||
vim.g.copilot_no_tab_map = true
|
||||
vim.api.nvim_set_keymap("i", "<C-Tab>", 'copilot#Accept("<CR>")', { silent = true, expr = true })
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
local null_ls = require("null-ls")
|
||||
|
||||
local no_really = {
|
||||
method = null_ls.methods.DIAGNOSTICS,
|
||||
filetypes = { "markdown", "text", "tex" },
|
||||
generator = {
|
||||
fn = function(params)
|
||||
local diagnostics = {}
|
||||
-- sources have access to a params object
|
||||
-- containing info about the current file and editor state
|
||||
for i, line in ipairs(params.content) do
|
||||
local col, end_col = line:find("really")
|
||||
if col and end_col then
|
||||
-- null-ls fills in undefined positions
|
||||
-- and converts source diagnostics into the required format
|
||||
table.insert(diagnostics, {
|
||||
row = i,
|
||||
col = col,
|
||||
end_col = end_col + 1,
|
||||
source = "no-really",
|
||||
message = "Don't use 'really!'",
|
||||
severity = vim.diagnostic.severity.WARN,
|
||||
})
|
||||
end
|
||||
end
|
||||
return diagnostics
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
null_ls.register(no_really)
|
Loading…
Reference in New Issue