Use null-ls for liniting where available

This commit is contained in:
ViViDboarder 2021-12-08 15:28:12 -08:00
parent 89cb90a6aa
commit b8b502298e
4 changed files with 59 additions and 16 deletions

View File

@ -16,6 +16,9 @@ local function config_dark_notify()
}
end
-- Disable polyglot for langauges I've added special support for
vim.g.polyglot_disabled = { "go", "rust" }
return require('packer').startup(function()
-- luacheck: push globals use
use "wbthomason/packer.nvim"
@ -101,11 +104,19 @@ return require('packer').startup(function()
}
-- LSP
use {
"jose-elias-alvarez/null-ls.nvim",
config = function() require("plugins.lsp").config_null_ls() end,
requires = {
"nvim-lua/plenary.nvim",
}
}
use {
"neovim/nvim-lspconfig",
config = function() require("plugins.lsp").config_lsp() end,
requires = {
"hrsh7th/cmp-nvim-lsp",
"jose-elias-alvarez/null-ls.nvim",
},
}
use {
@ -131,7 +142,6 @@ return require('packer').startup(function()
requires = "kana/vim-textobj-user",
}
-- Treesitter
use {
"nvim-treesitter/nvim-treesitter",
@ -225,7 +235,6 @@ return require('packer').startup(function()
use {
'sheerun/vim-polyglot',
config = function()
vim.g.polyglot_disabled = { "go", "rust" }
vim.cmd([[
augroup ansible_playbook
au BufRead,BufNewFile */playbooks/*.yml,*/playbooks/*.yaml set filetype=yaml.ansible
@ -233,14 +242,6 @@ return require('packer').startup(function()
]])
end,
}
--[[
use {
"fatih/vim-go",
config = function()
vim.g.go_code_completion_enabled = 0
end,
}
--]]
use {
"dense-analysis/ale",

View File

@ -1,13 +1,12 @@
vim.g["airline#extensions#ale#enabled"] = 1
vim.g.ale_lint_on_enter = 0
vim.g.ale_go_golangci_lint_package = 1
vim.g.ale_disable_lsp = 1
vim.g.ale_linters = {
go = {'gopls', 'golint', 'golangci-lint'},
-- go = {"golangci-lint"},
-- rust = {'rls', 'cargo'},
rust = {"cargo"},
go = {},
rust = {},
-- sh = {'language_server', 'shell', 'shellcheck'},
sh = {"shell", "shellcheck"},
sh = {},
text = {"proselint", "alex"},
}
vim.g.ale_linter_aliases = {

View File

@ -16,6 +16,14 @@ function M.config_cmp()
{name = "buffer"},
{name = "spell"},
},
--[[
mapping = {
['<C-Space>'] = cmp.mapping({
i = cmp.mapping.complete(),
c = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
}),
},
--]]
}
-- Add a plug mapping to use in C-Space binding

View File

@ -37,7 +37,7 @@ local function default_attach(client, bufnr)
vim.cmd([[
augroup lsp_format
autocmd!
autocmd BufWritePre *.rs,*.go lua vim.lsp.buf.formatting_sync(nil, 1000)
autocmd BufWritePre *.rs,*.go,*.py lua vim.lsp.buf.formatting_sync(nil, 1000)
" autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 1000)
augroup END
]])
@ -97,6 +97,9 @@ function M.config_lsp()
if utils.is_plugin_loaded("cmp-nvim-lsp") then
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
end
if utils.is_plugin_loaded("null-ls.nvim") then
table.insert(language_servers, "null-ls")
end
for _, ls in ipairs(language_servers) do
lsp_config[ls].setup{
@ -133,4 +136,36 @@ function M.config_lsp_saga()
}
end
function M.config_null_ls()
local null_ls = require("null-ls")
null_ls.config{
sources = {
-- Generic
-- null_ls.builtins.formatting.preittier,
-- null_ls.builtins.formatting.trim_whitespace,
-- null_ls.builtins.formatting.trim_newlines,
-- Fish
-- null_ls.builtins.formatting.fish_indent,
-- Python
-- null_ls.builtins.formatting.reorder_python_imports,
-- null_ls.builtins.formatting.black,
-- Go
null_ls.builtins.diagnostics.golangci_lint,
-- Text
-- null_ls.builtins.code_actions.proselint,
-- Ansible
-- null_ls.builtins.diagnostics.ansiblelint,
-- Shell
null_ls.builtins.diagnostics.shellcheck,
-- Rust
-- null_ls.builtins.formatting.rustfmt,
},
}
--[[
require("lspconfig")["null-ls"].setup{
on_attach=default_attach,
}
--]]
end
return M