🐛 fix(nvim): changed a lot of stuff to adapt to the new 10.0 lazyvim update

the new lazyvim update was huge, especially because none-ls was moved to extras, so conform and lint
would be the default formatter-linting
This commit is contained in:
Sergio Laín 2023-10-13 14:06:10 +02:00
parent c80a50087a
commit 438af606a1
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
21 changed files with 812 additions and 616 deletions

31
.config/nvim/lazyvim.json Normal file
View file

@ -0,0 +1,31 @@
{
"extras": [
"lazyvim.plugins.extras.coding.yanky",
"lazyvim.plugins.extras.dap.core",
"lazyvim.plugins.extras.dap.nlua",
"lazyvim.plugins.extras.editor.symbols-outline",
"lazyvim.plugins.extras.formatting.black",
"lazyvim.plugins.extras.formatting.prettier",
"lazyvim.plugins.extras.lang.docker",
"lazyvim.plugins.extras.lang.go",
"lazyvim.plugins.extras.lang.java",
"lazyvim.plugins.extras.lang.json",
"lazyvim.plugins.extras.lang.omnisharp",
"lazyvim.plugins.extras.lang.python",
"lazyvim.plugins.extras.lang.rust",
"lazyvim.plugins.extras.lang.tailwind",
"lazyvim.plugins.extras.lang.typescript",
"lazyvim.plugins.extras.lang.yaml",
"lazyvim.plugins.extras.linting.eslint",
"lazyvim.plugins.extras.test.core",
"lazyvim.plugins.extras.ui.alpha",
"lazyvim.plugins.extras.util.dot",
"lazyvim.plugins.extras.util.project",
"lazyvim.plugins.extras.vscode",
"plugins.extras.alpha"
],
"news": {
"NEWS.md": "2123"
},
"version": 2
}

View file

@ -76,9 +76,9 @@ map("n", "<leader>si", ":Telescope import<CR>", { desc = "Imports" })
map("n", "<leader>sI", ":Gitignore<CR>", { desc = "Gitignore" }) map("n", "<leader>sI", ":Gitignore<CR>", { desc = "Gitignore" })
map("n", "<leader>um", ":MarkdownPreviewToggle<CR>", { desc = "Toggle Markdown Preview" }) map("n", "<leader>cC", ":ConformInfo<CR>", { desc = "Conform Info" })
map("n", "<leader>cn", ":NullLsInfo<CR>", { desc = "NullLs Info" }) map("n", "<leader>um", ":MarkdownPreviewToggle<CR>", { desc = "Toggle Markdown Preview" })
map( map(
"n", "n",

View file

@ -11,24 +11,6 @@ require("lazy").setup({
spec = { spec = {
-- add LazyVim and import its plugins -- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" }, { "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import any extras modules here
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.dap.core" },
{ import = "lazyvim.plugins.extras.test.core" },
{ import = "lazyvim.plugins.extras.lang.python" },
{ import = "lazyvim.plugins.extras.lang.docker" },
{ import = "lazyvim.plugins.extras.lang.go" },
{ import = "lazyvim.plugins.extras.lang.rust" },
{ import = "lazyvim.plugins.extras.lang.tailwind" },
{ import = "lazyvim.plugins.extras.linting.eslint" },
{ import = "lazyvim.plugins.extras.formatting.prettier" },
-- { import = "lazyvim.plugins.extras.coding.copilot" },
{ import = "lazyvim.plugins.extras.util.dot" },
{ import = "lazyvim.plugins.extras.lang.yaml" },
{ import = "lazyvim.plugins.extras.coding.yanky" },
{ import = "lazyvim.plugins.extras.util.project" },
{ import = "lazyvim.plugins.extras.lang.omnisharp" },
{ import = "plugins" }, { import = "plugins" },
}, },
defaults = { defaults = {

View file

@ -2,8 +2,6 @@ return {
{ {
"windwp/nvim-ts-autotag", "windwp/nvim-ts-autotag",
event = "InsertEnter", event = "InsertEnter",
config = function() opts = {},
require("nvim-ts-autotag").setup()
end,
}, },
} }

View file

@ -0,0 +1,58 @@
return {
{
"stevearc/conform.nvim",
dependencies = { "mason.nvim" },
lazy = true,
cmd = "ConformInfo",
keys = {
{
"<leader>cF",
function()
require("conform").format({ formatters = { "injected" } })
end,
mode = { "n", "v" },
desc = "Format Injected Langs",
},
{
"<leader>cC",
":ConformInfo<CR>",
mode = { "n", "v" },
desc = "Conform Info",
},
},
opts = {
formatters_by_ft = {
lua = { "stylua" },
fish = { "fish_indent" },
sh = { "shfmt", "shellharden" },
python = { "isort", "black" },
bash = { "shfmt", "shellharden" },
javascript = { { "prettierd", "prettier", "rustywind" } },
javascriptreact = { { "prettierd", "prettier", "rustywind" } },
typescript = { { "prettierd", "prettier", "rustywind" } },
typescriptreact = { { "prettierd", "prettier", "rustywind" } },
vue = { { "prettierd", "prettier", "rustywind" } },
html = { { "prettierd", "prettier", "rustywind" } },
rust = { "rusfmt" },
go = { "gofumpt", "goimports" },
},
-- LazyVim will merge the options you set here with builtin formatters.
-- You can also define any custom formatters here.
---@type table<string,table>
formatters = {
injected = { options = { ignore_errors = true } },
-- -- Example of using dprint only when a dprint.json file is present
-- dprint = {
-- condition = function(ctx)
-- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1]
-- end,
-- },
taplo = {
condition = function(ctx)
return vim.fs.find({ "Cargo.toml" }, { path = ctx.filename, upward = true })[1]
end,
},
},
},
},
}

View file

@ -1,9 +1,8 @@
return { return {
{ {
"nvim-treesitter/nvim-treesitter-context", "nvim-treesitter/nvim-treesitter-context",
event = "BufReadPost", event = "LazyFile",
config = function() enabled = true,
require("treesitter-context").setup() opts = { mode = "cursor" },
end,
}, },
} }

View file

@ -1,104 +0,0 @@
return {
{
"mfussenegger/nvim-dap",
dependencies = {
-- fancy UI for the debugger
{
"rcarriga/nvim-dap-ui",
-- stylua: ignore
keys = {
{ "<leader>du", function() require("dapui").toggle({ }) end, desc = "Dap UI" },
{ "<leader>de", function() require("dapui").eval() end, desc = "Eval", mode = {"n", "v"} },
},
opts = {},
config = function(_, opts)
local dap = require("dap")
local dapui = require("dapui")
dapui.setup(opts)
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open({})
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close({})
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close({})
end
end,
},
-- virtual text for the debugger
{
"theHamsta/nvim-dap-virtual-text",
opts = {},
},
-- which key integration
{
"folke/which-key.nvim",
optional = true,
opts = {
defaults = {
["<leader>d"] = { name = "+debug" },
["<leader>da"] = { name = "+adapters" },
},
},
},
-- mason.nvim integration
{
"jay-babu/mason-nvim-dap.nvim",
dependencies = "mason.nvim",
cmd = { "DapInstall", "DapUninstall" },
opts = {
-- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations
automatic_installation = true,
-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information
handlers = {},
-- You'll need to check that you have the required things installed
-- online, please don't ask me how to install them :)
ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want
},
},
},
},
-- stylua: ignore
keys = {
{ "<leader>dc", function() require("dap").continue() end, desc = "Continue" },
{ "<leader>dC", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" },
{ "<leader>dg", function() require("dap").goto_() end, desc = "Go to line (no execute)" },
{ "<leader>di", function() require("dap").step_into() end, desc = "Step Into" },
{ "<leader>dj", function() require("dap").down() end, desc = "Down" },
{ "<leader>dk", function() require("dap").up() end, desc = "Up" },
{ "<leader>dl", function() require("dap").run_last() end, desc = "Run Last" },
{ "<leader>do", function() require("dap").step_out() end, desc = "Step Out" },
{ "<leader>dO", function() require("dap").step_over() end, desc = "Step Over" },
{ "<leader>dp", function() require("dap").pause() end, desc = "Pause" },
{ "<leader>dr", function() require("dap").repl.toggle() end, desc = "Toggle REPL" },
{ "<leader>ds", function() require("dap").session() end, desc = "Session" },
{ "<leader>dt", function() require("dap").terminate() end, desc = "Terminate" },
{ "<leader>dw", function() require("dap.ui.widgets").hover() end, desc = "Widgets" },
},
config = function()
local Config = require("lazyvim.config")
vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" })
for name, sign in pairs(Config.icons.dap) do
sign = type(sign) == "table" and sign or { sign }
vim.fn.sign_define(
"Dap" .. name,
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
)
end
end,
},
}

View file

@ -0,0 +1,75 @@
return {
{
"glepnir/dashboard-nvim",
event = "VimEnter",
opts = function()
local logo = [[
]]
-- local logo = [[
-- ▄ ▄
-- ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄
-- █ ▄ █▄█ ▄▄▄ █ █▄█ █ █
-- ▄▄ █▄█▄▄▄█ █▄█▄█▄▄█▄▄█ █
-- ▄ █▄▄█ ▄ ▄▄ ▄█ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄
-- █▄▄▄▄ ▄▄▄ █ ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ █ ▄
-- ▄ █ █▄█ █▄█ █ █ █▄█ █ █▄█ ▄▄▄ █ █
-- █▄█ ▄ █▄▄█▄▄█ █ ▄▄█ █ ▄ █ █▄█▄█ █
-- █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ █▄█▄▄▄█
-- ]]
logo = string.rep("\n", 8) .. logo .. "\n\n"
local opts = {
theme = "doom",
hide = {
-- this is taken care of by lualine
-- enabling this messes up the actual laststatus setting after loading a file
statusline = false,
},
config = {
header = vim.split(logo, "\n"),
center = {
{ action = "Telescope find_files", desc = " Find file", icon = "", key = "f" },
{ action = "ene | startinsert", desc = " New file", icon = "", key = "n" },
{ action = "Telescope oldfiles", desc = " Recent files", icon = "", key = "r" },
{ action = "Telescope live_grep", desc = " Find text", icon = "", key = "g" },
{ action = "e $MYVIMRC", desc = " Config", icon = "", key = "c" },
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = "", key = "s" },
{ action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" },
{ action = "qa", desc = " Quit", icon = "", key = "q" },
},
footer = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" }
end,
},
}
for _, button in ipairs(opts.config.center) do
button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
end
-- close Lazy and re-open when the dashboard is ready
if vim.o.filetype == "lazy" then
vim.cmd.close()
vim.api.nvim_create_autocmd("User", {
pattern = "DashboardLoaded",
callback = function()
require("lazy").show()
end,
})
end
return opts
end,
},
}

View file

@ -0,0 +1,103 @@
return {
{
"mfussenegger/nvim-dap",
dependencies = {
-- fancy UI for the debugger
{
"rcarriga/nvim-dap-ui",
-- stylua: ignore
keys = {
{ "<leader>du", function() require("dapui").toggle({ }) end, desc = "Dap UI" },
{ "<leader>de", function() require("dapui").eval() end, desc = "Eval", mode = {"n", "v"} },
},
opts = {},
config = function(_, opts)
local dap = require("dap")
local dapui = require("dapui")
dapui.setup(opts)
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open({})
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close({})
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close({})
end
end,
},
-- virtual text for the debugger
{
"theHamsta/nvim-dap-virtual-text",
opts = {},
},
-- which key integration
{
"folke/which-key.nvim",
optional = true,
opts = {
defaults = {
["<leader>d"] = { name = "+debug" },
},
},
},
-- mason.nvim integration
{
"jay-babu/mason-nvim-dap.nvim",
dependencies = "mason.nvim",
cmd = { "DapInstall", "DapUninstall" },
opts = {
-- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations
automatic_installation = true,
-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information
handlers = {},
-- You'll need to check that you have the required things installed
-- online, please don't ask me how to install them :)
ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want
},
},
},
},
-- stylua: ignore
keys = {
{ "<leader>dc", function() require("dap").continue() end, desc = "Continue" },
{ "<leader>dC", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" },
{ "<leader>dg", function() require("dap").goto_() end, desc = "Go to line (no execute)" },
{ "<leader>di", function() require("dap").step_into() end, desc = "Step Into" },
{ "<leader>dj", function() require("dap").down() end, desc = "Down" },
{ "<leader>dk", function() require("dap").up() end, desc = "Up" },
{ "<leader>dl", function() require("dap").run_last() end, desc = "Run Last" },
{ "<leader>do", function() require("dap").step_out() end, desc = "Step Out" },
{ "<leader>dO", function() require("dap").step_over() end, desc = "Step Over" },
{ "<leader>dp", function() require("dap").pause() end, desc = "Pause" },
{ "<leader>dr", function() require("dap").repl.toggle() end, desc = "Toggle REPL" },
{ "<leader>ds", function() require("dap").session() end, desc = "Session" },
{ "<leader>dt", function() require("dap").terminate() end, desc = "Terminate" },
{ "<leader>dw", function() require("dap.ui.widgets").hover() end, desc = "Widgets" },
},
config = function()
local Config = require("lazyvim.config")
vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" })
for name, sign in pairs(Config.icons.dap) do
sign = type(sign) == "table" and sign or { sign }
vim.fn.sign_define(
"Dap" .. name,
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
)
end
end,
},
}

View file

@ -0,0 +1,30 @@
return {
{
"mfussenegger/nvim-lint",
event = "LazyFile",
opts = {
-- Event to trigger linters
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
linters_by_ft = {
fish = { "fish" },
markdown = { "markdownlint" },
python = { "pylint" },
yaml = { "yamllint" },
dockerfile = { "hadolint" },
},
-- LazyVim extension to easily override linter options
-- or add custom linters.
---@type table<string,table>
linters = {
-- -- Example of using selene only when a selene.toml file is present
-- selene = {
-- -- `condition` is another LazyVim extension that allows you to
-- -- dynamically enable/disable linters based on the context.
-- condition = function(ctx)
-- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1]
-- end,
-- },
},
},
},
}

View file

@ -6,7 +6,7 @@ return {
end, end,
cmd = { "LiveServer", "LiveServerStart", "LiveServerStop" }, cmd = { "LiveServer", "LiveServerStart", "LiveServerStop" },
keys = { keys = {
{ "<leader>cs", "<cmd>LiveServer<CR>", desc = "Toggle LiveServer" }, { "<leader>cL", "<cmd>LiveServer<CR>", desc = "Toggle LiveServer" },
}, },
}, },
} }

View file

@ -0,0 +1,9 @@
return {
{
"VidocqH/lsp-lens.nvim",
event = "BufReadPost",
config = function()
require("lsp-lens").setup()
end,
},
}

View file

@ -43,8 +43,6 @@ return {
}, },
-- add any global capabilities here -- add any global capabilities here
capabilities = {}, capabilities = {},
-- Automatically format on save
autoformat = true,
-- Enable this to show formatters used in a notification -- Enable this to show formatters used in a notification
-- Useful for debugging formatter issues -- Useful for debugging formatter issues
format_notify = false, format_notify = false,

View file

@ -2,15 +2,31 @@ return {
{ {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
event = "VeryLazy", event = "VeryLazy",
init = function()
vim.g.lualine_laststatus = vim.o.laststatus
if vim.fn.argc(-1) > 0 then
-- set an empty statusline till lualine loads
vim.o.statusline = " "
else
-- hide the statusline on the starter page
vim.o.laststatus = 0
end
end,
opts = function() opts = function()
-- PERF: we don't need this lualine require madness 🤷
local lualine_require = require("lualine_require")
lualine_require.require = require
local icons = require("lazyvim.config").icons local icons = require("lazyvim.config").icons
local Util = require("lazyvim.util") local Util = require("lazyvim.util")
vim.o.laststatus = vim.g.lualine_laststatus
return { return {
options = { options = {
theme = "catppuccin", theme = "catppuccin",
globalstatus = true, globalstatus = true,
disabled_filetypes = { statusline = { "dashboard", "alpha" } }, disabled_filetypes = { statusline = { "dashboard", "alpha", "starter" } },
component_separators = "", component_separators = "",
section_separators = { left = "", right = "" }, section_separators = { left = "", right = "" },
}, },
@ -28,8 +44,12 @@ return {
}, },
}, },
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
{ "filename", path = 1, symbols = { modified = "", readonly = "", unnamed = "" } }, {
-- stylua: ignore function()
return Util.root.pretty_path()
end,
},
-- stylua: ignore
{ {
function() function()
local ok, m = pcall(require, "better_escape") local ok, m = pcall(require, "better_escape")
@ -42,24 +62,24 @@ return {
{ {
function() return require("noice").api.status.command.get() end, function() return require("noice").api.status.command.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end,
color = Util.fg("Statement"), color = Util.ui.fg("Statement"),
}, },
-- stylua: ignore -- stylua: ignore
{ {
function() return require("noice").api.status.mode.get() end, function() return require("noice").api.status.mode.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end,
color = Util.fg("Constant"), color = Util.ui.fg("Constant"),
}, },
-- stylua: ignore -- stylua: ignore
{ {
function() return "" .. require("dap").status() end, function() return "" .. require("dap").status() end,
cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end,
color = Util.fg("Debug"), color = Util.ui.fg("Debug"),
}, },
{ {
require("lazy.status").updates, require("lazy.status").updates,
cond = require("lazy.status").has_updates, cond = require("lazy.status").has_updates,
color = Util.fg("Special"), color = Util.ui.fg("Special"),
}, },
{ {
"diff", "diff",
@ -70,7 +90,6 @@ return {
}, },
}, },
}, },
lualine_y = { lualine_y = {
{ "progress", separator = " ", padding = { left = 1, right = 1 } }, { "progress", separator = " ", padding = { left = 1, right = 1 } },
}, },

View file

@ -5,7 +5,6 @@ return {
ensure_installed = { ensure_installed = {
"black", "black",
"prettierd", "prettierd",
"beautysh",
"codespell", "codespell",
"csharpier", "csharpier",
"css-lsp", "css-lsp",
@ -16,14 +15,21 @@ return {
"rustywind", "rustywind",
"sqlfmt", "sqlfmt",
"markdownlint", "markdownlint",
"marksman",
"markuplint",
"stylua", "stylua",
"shfmt", "shfmt",
"angular-language-server", "angular-language-server",
"bash-language-server", "bash-language-server",
"omnisharp", "omnisharp",
"sqlls", "sqlls",
"goimports",
"shellharden",
"codelldb",
"markdownlint",
"pylint",
"gofumpt",
"delve",
"impl",
"gomodifytags",
}, },
}, },
}, },

View file

@ -1,3 +1,5 @@
local Util = require("lazyvim.util")
return { return {
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
@ -7,7 +9,7 @@ return {
{ {
"<leader>fe", "<leader>fe",
function() function()
require("neo-tree.command").execute({ toggle = true, dir = require("lazyvim.util").get_root() }) require("neo-tree.command").execute({ toggle = true, dir = Util.root() })
end, end,
desc = "Explorer NeoTree (root dir)", desc = "Explorer NeoTree (root dir)",
}, },

View file

@ -1,11 +0,0 @@
return {
{
"simrat39/symbols-outline.nvim",
event = "BufReadPost",
cmd = "SymbolsOutline",
keys = { { "<leader>ul", "<cmd>SymbolsOutline<cr>", desc = "Lsp Symbols Outline" } },
config = function()
require("symbols-outline").setup()
end,
},
}

View file

@ -39,7 +39,7 @@ return {
---@type TSConfig ---@type TSConfig
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
opts = { opts = {
autotag = { enable = true }, -- autotag = { enable = true },
endwise = { enable = true }, endwise = { enable = true },
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },

View file

@ -32,6 +32,7 @@ return {
["<leader>ss"] = { name = "+Goto Symbols" }, ["<leader>ss"] = { name = "+Goto Symbols" },
["<leader>db"] = { name = "+Breakpoints" }, ["<leader>db"] = { name = "+Breakpoints" },
["<leader>sr"] = { name = "+replace" }, ["<leader>sr"] = { name = "+replace" },
["<leader>dP"] = { name = "+python" },
}, },
}, },
config = function(_, opts) config = function(_, opts)