nvim lazy plugin management part 2
This commit is contained in:
30
.config/nvim/lua/user/plugins/lsp/diagnostics_config.lua
Normal file
30
.config/nvim/lua/user/plugins/lsp/diagnostics_config.lua
Normal file
@ -0,0 +1,30 @@
|
||||
local M = {}
|
||||
|
||||
M.setup = function()
|
||||
local config = {
|
||||
virtual_text = true,
|
||||
signs = {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = '',
|
||||
[vim.diagnostic.severity.WARN] = '',
|
||||
[vim.diagnostic.severity.HINT] = '',
|
||||
[vim.diagnostic.severity.INFO] = '',
|
||||
}
|
||||
},
|
||||
update_in_insert = true,
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
focusable = true,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
}
|
||||
|
||||
vim.diagnostic.config(config)
|
||||
end
|
||||
|
||||
return M
|
||||
34
.config/nvim/lua/user/plugins/lsp/init.lua
Normal file
34
.config/nvim/lua/user/plugins/lsp/init.lua
Normal file
@ -0,0 +1,34 @@
|
||||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
event = "VeryLazy",
|
||||
config = true
|
||||
}, -- simple to use language server installer
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("user.plugins.lsp.mason_lsp_config")
|
||||
require("user.plugins.lsp.diagnostics_config").setup()
|
||||
-- require("user.lsp.none_ls")
|
||||
|
||||
vim.cmd([[ command! Format execute 'lua vim.lsp.buf.format{async=true}' ]])
|
||||
end
|
||||
},
|
||||
{ "neovim/nvim-lspconfig", event = "VeryLazy" }, -- enable LSP
|
||||
{
|
||||
"lukas-reineke/lsp-format.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
local on_attach = function(client)
|
||||
require("lsp-format").on_attach(client)
|
||||
end
|
||||
|
||||
require("lspconfig").gopls.setup { on_attach = on_attach }
|
||||
end
|
||||
},
|
||||
{
|
||||
"nvimtools/none-ls.nvim",
|
||||
event = "VeryLazy"
|
||||
},
|
||||
}
|
||||
48
.config/nvim/lua/user/plugins/lsp/mason_lsp_config.lua
Normal file
48
.config/nvim/lua/user/plugins/lsp/mason_lsp_config.lua
Normal file
@ -0,0 +1,48 @@
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
|
||||
vim.lsp.enable({
|
||||
"omnisharp",
|
||||
"pylsp",
|
||||
"rust_analyzer",
|
||||
})
|
||||
|
||||
-- TODO: this does not work, need to install pylsp-mypy plugin manually
|
||||
local function extra_args()
|
||||
local virtual = os.getenv("VIRTUAL_ENV") or "/usr"
|
||||
return { "--python-executable", virtual .. "/bin/python3", true }
|
||||
end
|
||||
|
||||
vim.lsp.config('pylsp', {
|
||||
settings = {
|
||||
["pylsp"] = {
|
||||
enabled = true,
|
||||
plugins = {
|
||||
pycodestyle = {
|
||||
ignore = { "E501", "E231", "W503" },
|
||||
maxLineLength = 100,
|
||||
},
|
||||
pyls_isort = { enabled = true },
|
||||
pylsp_mypy = {
|
||||
enabled = true,
|
||||
-- this will make mypy to use the virtual environment
|
||||
-- if not activated then it will use the system python(more specifically /usr/bin/python3)
|
||||
overrides = extra_args(),
|
||||
report_progress = true,
|
||||
live_mode = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
vim.lsp.config('rust_analyzer', {
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
cargo = {
|
||||
features = "all",
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
mason_lspconfig.setup()
|
||||
25
.config/nvim/lua/user/plugins/lsp/none_ls.lua
Normal file
25
.config/nvim/lua/user/plugins/lsp/none_ls.lua
Normal file
@ -0,0 +1,25 @@
|
||||
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
|
||||
if not null_ls_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local formatting = null_ls.builtins.formatting
|
||||
local diagnostics = null_ls.builtins.diagnostics
|
||||
|
||||
null_ls.builtins.diagnostics.mypy.with({
|
||||
extra_args = function()
|
||||
local virtual = os.getenv("VIRTUAL_ENV") or "/usr"
|
||||
return { "--python-executable", virtual .. "/bin/python3" }
|
||||
end,
|
||||
})
|
||||
|
||||
null_ls.setup({
|
||||
debug = false,
|
||||
sources = {
|
||||
-- formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }),
|
||||
-- formatting.black.with({ extra_args = { "--fast" } }),
|
||||
-- formatting.isort,
|
||||
formatting.stylua,
|
||||
-- diagnostics.mypy,
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user