nvim-lint: deadnix
This commit is contained in:
parent
796fd8d12c
commit
22992b80a4
3 changed files with 23 additions and 4 deletions
|
@ -5,7 +5,7 @@
|
||||||
(fn mod.setup []
|
(fn mod.setup []
|
||||||
(let [augroup (vim.api.nvim_create_augroup :NifocFormatting {:clear true})
|
(let [augroup (vim.api.nvim_create_augroup :NifocFormatting {:clear true})
|
||||||
aucmd vim.api.nvim_create_autocmd]
|
aucmd vim.api.nvim_create_autocmd]
|
||||||
(aucmd :BufWritePre {:callback #(mod.maybe-format-buffer) :group augroup})))
|
(aucmd :BufWritePre {:callback mod.maybe-format-buffer :group augroup})))
|
||||||
|
|
||||||
(fn mod.maybe-enable-lsp [client bufnr]
|
(fn mod.maybe-enable-lsp [client bufnr]
|
||||||
(when client.server_capabilities.documentRangeFormattingProvider
|
(when client.server_capabilities.documentRangeFormattingProvider
|
||||||
|
|
|
@ -1,16 +1,34 @@
|
||||||
(let [lint (require :lint)
|
(let [lint (require :lint)
|
||||||
augroup (vim.api.nvim_create_augroup :NifocLint {:clear true})
|
augroup (vim.api.nvim_create_augroup :NifocLint {:clear true})
|
||||||
aucmd vim.api.nvim_create_autocmd]
|
aucmd vim.api.nvim_create_autocmd]
|
||||||
|
(set lint.linters.deadnix
|
||||||
|
{:cmd :deadnix
|
||||||
|
:stdin false
|
||||||
|
:args [:--output-format :json]
|
||||||
|
:stream :stdout
|
||||||
|
:ignore_exitcode false
|
||||||
|
:parser (fn [output]
|
||||||
|
(if (= output "") {}
|
||||||
|
(let [findings (vim.json.decode output)]
|
||||||
|
(vim.tbl_map (fn [result]
|
||||||
|
{:lnum (- result.line 1)
|
||||||
|
:end_lnum (- result.line 1)
|
||||||
|
:col (- result.column 1)
|
||||||
|
:end_col (- result.endColumn 1)
|
||||||
|
:severity vim.diagnostic.severity.HINT
|
||||||
|
:source :deadnix
|
||||||
|
:message result.message})
|
||||||
|
findings.results))))})
|
||||||
(set lint.linters_by_ft {:dockerfile [:hadolint]
|
(set lint.linters_by_ft {:dockerfile [:hadolint]
|
||||||
:elixir [:credo]
|
:elixir [:credo]
|
||||||
:fennel [:fennel]
|
:fennel [:fennel]
|
||||||
:nix [:nix :statix]
|
:nix [:deadnix :nix :statix]
|
||||||
:sh [:shellcheck]})
|
:sh [:shellcheck]})
|
||||||
|
|
||||||
(fn setup-linting [opts]
|
(fn setup-linting [opts]
|
||||||
(aucmd [:BufWritePost :BufWinEnter :InsertLeave]
|
(aucmd [:BufWritePost :BufEnter :InsertLeave]
|
||||||
{:callback #(lint.try_lint) :buffer opts.buf :group augroup}))
|
{:callback #(lint.try_lint) :buffer opts.buf :group augroup}))
|
||||||
|
|
||||||
(each [ft _ (pairs lint.linters_by_ft)]
|
(each [ft _ (pairs lint.linters_by_ft)]
|
||||||
(aucmd :InsertEnter {:pattern ft :callback setup-linting :group augroup})))
|
(aucmd :FileType {:pattern ft :callback setup-linting :group augroup})))
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ in
|
||||||
# LSP Tools
|
# LSP Tools
|
||||||
deadnix
|
deadnix
|
||||||
hadolint
|
hadolint
|
||||||
|
fennel
|
||||||
fnlfmt
|
fnlfmt
|
||||||
shellcheck
|
shellcheck
|
||||||
shfmt
|
shfmt
|
||||||
|
|
Loading…
Reference in a new issue