NEW: null-ls diagnostics with vale

This commit is contained in:
Jean-Claude 2022-06-13 11:26:22 +02:00
parent a33ec1cd07
commit 8b74093b01
Signed by: jeanclaude
GPG Key ID: 8A300F57CBB9F63E
19 changed files with 94 additions and 7 deletions

21
.gitmodules vendored
View File

@ -0,0 +1,21 @@
[submodule "language/vale/StyleRepos/Microsoft"]
path = language/vale/StyleRepos/Microsoft
url = https://github.com/errata-ai/Microsoft
[submodule "language/vale/StyleRepos/Google"]
path = language/vale/StyleRepos/Google
url = https://github.com/errata-ai/Google
[submodule "language/vale/StyleRepos/write-good"]
path = language/vale/StyleRepos/write-good
url = https://github.com/errata-ai/write-good
[submodule "language/vale/StyleRepos/proselint"]
path = language/vale/StyleRepos/proselint
url = https://github.com/errata-ai/proselint
[submodule "language/vale/StyleRepos/readability"]
path = language/vale/StyleRepos/readability
url = https://github.com/errata-ai/readability
[submodule "language/vale/StyleRepos/alex"]
path = language/vale/StyleRepos/alex
url = https://github.com/errata-ai/alex
[submodule "language/vale/StyleRepos/Joblint"]
path = language/vale/StyleRepos/Joblint
url = https://github.com/errata-ai/Joblint

View File

@ -36,6 +36,12 @@ keymap('v', '>', '>gv')
keymap('n', '<leader>c', ':ColorizerToggle<CR>')
--buf_keymap(bufnr, 'n', '<leader>d','<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>')
keymap('n', '<leader>d', '<cmd>lua vim.diagnostic.open_float()<CR>')
keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>')
keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>')
keymap('n', '<leader>D', '<cmd>lua vim.diagnostic.setloclist()<CR>')
--" Open and close folds
--"nnoremap <leader>f zA

View File

@ -41,11 +41,11 @@ local function config(_config)
buf_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>')
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
--buf_keymap(bufnr, 'n', '<leader>d','<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>')
buf_keymap(bufnr, 'n', '<leader>d', '<cmd>lua vim.diagnostic.open_float()<CR>')
buf_keymap(bufnr, 'n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>')
buf_keymap(bufnr, 'n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>')
buf_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.diagnostic.setloclist()<CR>')
----buf_keymap(bufnr, 'n', '<leader>d','<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>')
--buf_keymap(bufnr, 'n', '<leader>d', '<cmd>lua vim.diagnostic.open_float()<CR>')
--buf_keymap(bufnr, 'n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>')
--buf_keymap(bufnr, 'n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>')
--buf_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.diagnostic.setloclist()<CR>')
end
-- -- Set autocommands conditional on server_capabilities
---- if client.resolved_capabilities.document_highlight then

View File

@ -1,10 +1,37 @@
local null_ls = require "null-ls"
local null_ls = require 'null-ls'
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
local formatting = null_ls.builtins.formatting
local severities = { error = 1, warning = 2, suggestion = 4 }
null_ls.setup {
sources = {
diagnostics.vale.with({
extra_filetypes = { 'txt' },
-- TODO make xdg dir work
--extra_args = { '--config=' .. vim.fs.normalize('$XDG_CONFIG_HOME/vale/vale.ini') },
extra_args = { '--config=/home/jeanclaude/.config/vale/vale.ini' },
-- From source https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/lua/null-ls/builtins/diagnostics/vale.lua
on_output = function(params)
local output = params.output["stdin." .. vim.fn.fnamemodify(params.bufname, ":e")]
or params.output[params.bufname]
or {}
local diag = {}
for _, diagnostic in ipairs(output) do
table.insert(diag, {
row = diagnostic.Line,
col = diagnostic.Span[1],
end_col = diagnostic.Span[2] + 1,
code = diagnostic.Check,
message = diagnostic.Message .. ' (' .. diagnostic.Check .. ')',
severity = severities[diagnostic.Severity],
})
end
return diag
end,
}),
formatting.black,
formatting.stylua,
diagnostics.flake8,

@ -0,0 +1 @@
Subproject commit 9d31bf781694a3f2fbd0e1cc4d93dd61d1e3c447

@ -0,0 +1 @@
Subproject commit 0be7f386e90ac7490663d7582754f0179a69d882

@ -0,0 +1 @@
Subproject commit 26acca62396038d7c46a56ea631c2a5261edf767

@ -0,0 +1 @@
Subproject commit 8eba173f027a5e75043e552cb7edd1f355dd6c9b

@ -0,0 +1 @@
Subproject commit f9cc800a459bddebdac1ad517bc2bc4b5522153d

@ -0,0 +1 @@
Subproject commit 04fe2a19dc2b4d3df237345639a6c048d8b66e2c

@ -0,0 +1 @@
Subproject commit 2d116619b7662d9d59201e8808254e715fc83cc8

1
language/vale/Styles/Google Symbolic link
View File

@ -0,0 +1 @@
../StyleRepos/Google/Google

View File

@ -0,0 +1 @@
../StyleRepos/Joblint/Joblint

View File

@ -0,0 +1 @@
../StyleRepos/Microsoft/Microsoft

View File

@ -0,0 +1 @@
../StyleRepos/readability/Readability

1
language/vale/Styles/alex Symbolic link
View File

@ -0,0 +1 @@
../StyleRepos/alex/alex/

View File

@ -0,0 +1 @@
../StyleRepos/proselint/proselint

View File

@ -0,0 +1 @@
../StyleRepos/write-good/write-good

19
language/vale/vale.ini Normal file
View File

@ -0,0 +1,19 @@
StylesPath = ./Styles
MinAlertLevel = suggestion
IgnoredScopes = code, tt
#IgnoredClasses = my-class, another-class
SkippedScopes = script, style, pre, figure
WordTemplate = \b(?:%s)\b
[*.txt]
BasedOnStyles = Microsoft, Google, proselint, write-good, Joblint, alex, Readability
[*.md]
BasedOnStyles = Microsoft, Google, proselint, write-good, Joblint, alex, Readability