diff --git a/lazy-lock.json b/lazy-lock.json index 70ef101..2d9ab65 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -12,7 +12,6 @@ "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "formatter.nvim": { "branch": "master", "commit": "eb89a1f3e079f1b9680bc7293b75fffccb5e1598" }, "gitsigns.nvim": { "branch": "main", "commit": "4c40357994f386e72be92a46f41fc1664c84c87d" }, - "incline.nvim": { "branch": "main", "commit": "0eb5b7f6fc6636a4e7b2eb2800b7650fd6d164a2" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, "lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" }, @@ -24,18 +23,18 @@ "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, "nui.nvim": { "branch": "main", "commit": "8d3bce9764e627b62b07424e0df77f680d47ffdb" }, "nvim-cmp": { "branch": "main", "commit": "c27370703e798666486e3064b64d59eaf4bdc6d5" }, + "nvim-lint": { "branch": "master", "commit": "6e9dd545a1af204c4022a8fcd99727ea41ffdcc8" }, "nvim-lspconfig": { "branch": "master", "commit": "fd26f8626c03b424f7140d454031d1dcb8d23513" }, "nvim-notify": { "branch": "master", "commit": "22f29093eae7785773ee9d543f8750348b1a195c" }, "nvim-treesitter": { "branch": "master", "commit": "38959800c2439c890e3238af559f0dc3be45e393" }, "nvim-web-devicons": { "branch": "master", "commit": "ab4cfee554e501f497bce0856788d43cf2eb93d7" }, + "persistence.nvim": { "branch": "main", "commit": "166a79a55bfa7a4db3e26fc031b4d92af71d0b51" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "render-markdown.nvim": { "branch": "main", "commit": "a03ed82dfdeb1a4980093609ffe94c171ace8059" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, - "telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" }, "telescope.nvim": { "branch": "master", "commit": "814f102cd1da3dc78c7d2f20f2ef3ed3cdf0e6e4" }, "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "de01d4c9cd032d4dac69bf64d5a184fbe62e1fd1" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, - "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, "typr": { "branch": "main", "commit": "5ee7b67dc610e8ec2c0c8a6912a8d1fba90160c2" }, diff --git a/lua/plugins/colorschemes/tokyonight.lua b/lua/plugins/colorschemes/tokyonight.lua index 3e7e943..bfc0750 100644 --- a/lua/plugins/colorschemes/tokyonight.lua +++ b/lua/plugins/colorschemes/tokyonight.lua @@ -2,7 +2,4 @@ return { "folke/tokyonight.nvim", lazy = true, opts = {}, - config = function() - vim.cmd("colorscheme tokyonight-night") - end, } diff --git a/lua/plugins/formatter.lua b/lua/plugins/formatter.lua index 308dd71..8a30c16 100644 --- a/lua/plugins/formatter.lua +++ b/lua/plugins/formatter.lua @@ -11,8 +11,6 @@ local function opts() } return { - logging = true, - log_level = vim.log.levels.WARN, filetype = { lua = { require("formatter.filetypes.lua").stylua, @@ -39,7 +37,8 @@ local function opts() require("formatter.filetypes.r").styler, }, python = { - require("formatter.filetypes.python").black, + require("formatter.filetypes.python").ruff, + require("formatter.filetypes.python").isort, }, json = { prettier, diff --git a/lua/plugins/linting.lua b/lua/plugins/linting.lua new file mode 100644 index 0000000..e5c4282 --- /dev/null +++ b/lua/plugins/linting.lua @@ -0,0 +1,67 @@ +return { + "mfussenegger/nvim-lint", + opts = { + -- Event to trigger linters + linters_by_ft = { + fish = { "fish" }, + nix = { "nix" }, + python = { "ruff" }, + }, + events = { "BufWritePost", "BufReadPost", "InsertLeave" }, + }, + config = function(_, opts) + local lint = require("lint") + local M = {} + lint.linters_by_ft = opts.linters_by_ft or {} + + function M.debounce(ms, fn) + local timer = vim.uv.new_timer() + return function(...) + local argv = { ... } + timer:start(ms, 0, function() + timer:stop() + vim.schedule_wrap(fn)(unpack(argv)) + end) + end + end + + function M.lint() + -- Use nvim-lint's logic first: + -- * checks if linters exist for the full filetype first + -- * otherwise will split filetype by "." and add all those linters + -- * this differs from conform.nvim which only uses the first filetype that has a formatter + local names = lint._resolve_linter_by_ft(vim.bo.filetype) + + -- Create a copy of the names table to avoid modifying the original. + names = vim.list_extend({}, names) + + -- Add fallback linters. + if #names == 0 then + vim.list_extend(names, lint.linters_by_ft["_"] or {}) + end + + -- Add global linters. + vim.list_extend(names, lint.linters_by_ft["*"] or {}) + + -- Filter out linters that don't exist or don't match the condition. + local ctx = { filename = vim.api.nvim_buf_get_name(0) } + ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") + names = vim.tbl_filter(function(name) + local linter = lint.linters[name] + if not linter then + vim.notify("Linter not found: " .. name, vim.log.levels.WARN, { title = "nvim-lint" }) + end + return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) + end, names) + + -- Run linters. + if #names > 0 then + lint.try_lint(names) + end + end + vim.api.nvim_create_autocmd(opts.events or {}, { + group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }), + callback = M.debounce(100, M.lint), + }) + end, +} diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index f7e6a1e..78a5aec 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -1,6 +1,7 @@ return { "neovim/nvim-lspconfig", -- Configurations for Nvim LSP opts = {}, + lazy = false, config = function() local lspconfig = require("lspconfig") @@ -71,4 +72,7 @@ return { end, }) end, + keys = { + { "r", vim.lsp.buf.rename, desc = "Rename a token" }, + }, } diff --git a/lua/plugins/main.lua b/lua/plugins/main.lua index ca7d2a2..8987f2d 100644 --- a/lua/plugins/main.lua +++ b/lua/plugins/main.lua @@ -1,40 +1,18 @@ --- vim:fileencoding=utf-8:foldmethod=marker - return { - --: Behaviour {{{ { "MeanderingProgrammer/render-markdown.nvim", dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.icons" }, -- if you use standalone mini plugins ---@module 'render-markdown' ---@type render.md.UserConfig opts = {}, + ft = "md", }, "preservim/nerdcommenter", -- (batch)commenting tool - { - "nvim-telescope/telescope-file-browser.nvim", - dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }, - opts = { - extensions = { - file_browser = { - theme = "ivy", - hijack_netrw = true, - auto_depth = true, - no_ignore = false, - hidden = { file_browser = true, folder_browser = true }, - }, - }, - }, - config = function(_, opts) - require("telescope").setup(opts) - require("telescope").load_extension("file_browser") - end, - }, "direnv/direnv.vim", - --:}}} - --: Visuals {{u{ { "rachartier/tiny-inline-diagnostic.nvim", event = "LspAttach", + lazy = false, opts = { options = { show_all_diags_on_cursorline = true, @@ -69,10 +47,7 @@ return { "lewis6991/gitsigns.nvim", }, opts = { - -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: animation = true, - -- insert_at_start = true, - -- …etc. }, }, { @@ -88,9 +63,5 @@ return { vim.notify = require("notify") end, }, - { - "stevearc/dressing.nvim", - }, - - --:}}} + "stevearc/dressing.nvim", } diff --git a/lua/plugins/persistence.lua b/lua/plugins/persistence.lua new file mode 100644 index 0000000..2c38d3d --- /dev/null +++ b/lua/plugins/persistence.lua @@ -0,0 +1,7 @@ +return { + "folke/persistence.nvim", + event = "BufReadPre", -- this will only start session saving when an actual file was opened + opts = { + -- add any custom options here + }, +} diff --git a/lua/plugins/snacks-explorer.lua b/lua/plugins/snacks-explorer.lua index 71fe63a..117c41e 100644 --- a/lua/plugins/snacks-explorer.lua +++ b/lua/plugins/snacks-explorer.lua @@ -1,13 +1,18 @@ return { "folke/snacks.nvim", - recommended = true, + lazy = false, ---@type snacks.Config - opts = { explorer = {} }, + opts = { + dim = {}, + dashboard = {}, + explorer = { replace_netrw = true }, + picker = { sources = { explorer = { hidden = true } } }, + }, keys = { { "e", function() - require("snacks").explorer() + require("snacks").explorer.open() end, desc = "Explorer Snacks (root dir)", }, diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 87f5c51..8016896 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -19,5 +19,10 @@ return { -- fuzzy file finder require("telescope.builtin").find_files, desc = "Find File", }, + { "fb", "Telescope buffers", desc = "Find Open Buffers" }, + { "fg", "Telescope live_grep", desc = "Live Grep" }, + { "fh", "Telescope help_tags", desc = "Find Help" }, + { "fi", "Telescope builtin", desc = "Search all Telescope builtins" }, + { "ft", "TodoTelescope ", desc = "Open Todo in Telescope" }, }, } diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua index 25d2135..6b92b40 100644 --- a/lua/plugins/which-key.lua +++ b/lua/plugins/which-key.lua @@ -12,20 +12,8 @@ return { end, desc = "Buffer Local Keymaps (which-key)", }, - { "bt", "BlameToggle virtual", desc = "Toggle Virtual Blame" }, - { "c", desc = "NerdCommenter" }, - { "f", desc = "Telescope - Finder" }, - { "fb", "Telescope buffers", desc = "Find Open Buffers" }, - { "fg", "Telescope live_grep", desc = "Live Grep" }, - { "fh", "Telescope help_tags", desc = "Find Help" }, - { "fi", "Telescope builtin", desc = "Search all Telescope builtins" }, - { "ft", "TodoTelescope ", desc = "Open Todo in Telescope" }, - { "fu", "UrlView", desc = "Display and open URLs in current buffer" }, - { "n", desc = "Terminal" }, - { "nb", "lua _Lazygit_toggle()", desc = "Open Lazygit" }, - { "nj", "ToggleTerm", desc = "Open Terminal" }, - { "r", "lua vim.lsp.buf.rename()", desc = "Rename a token" }, { "t1", "BufferGoto 1", desc = "Go to Buffer 1" }, - { "td", "BufferClose", desc = "Close Current Buffer" }, + { "h", "BufferPrevious", desc = "Go the previous Buffer" }, + { "l", "BufferNext", desc = "Go to the next Buffer" }, }, }