From d620f212915c8555024bf25b7daf4331196e89a8 Mon Sep 17 00:00:00 2001 From: ItaloBorrelli Date: Tue, 9 Sep 2025 11:36:52 -0700 Subject: [PATCH] Update zinit and nvim --- .../lua/plugins/file_navigation/neo-tree.lua | 42 +++++------ .../lua/plugins/language_support/conform.lua | 9 +-- .../plugins/language_support/nvim-lint.lua | 19 ++--- .config/nvim/lua/plugins/lsp/mason.lua | 1 + .../nvim/lua/plugins/lsp/nvim-lspconfig.lua | 70 ++++++------------- .../nvim/lua/plugins/util/auto-session.lua | 4 +- .zinit.zsh | 17 +++-- .zstyle.zsh | 41 +++++------ 8 files changed, 84 insertions(+), 119 deletions(-) diff --git a/.config/nvim/lua/plugins/file_navigation/neo-tree.lua b/.config/nvim/lua/plugins/file_navigation/neo-tree.lua index 85e6710..2591c7c 100644 --- a/.config/nvim/lua/plugins/file_navigation/neo-tree.lua +++ b/.config/nvim/lua/plugins/file_navigation/neo-tree.lua @@ -1,3 +1,4 @@ +local utils = require("utils") return { { "nvim-neo-tree/neo-tree.nvim", @@ -22,44 +23,39 @@ return { }) local keymap = vim.keymap - keymap.set("n", "e", function() + local opts = { noremap = true, silent = true } + utils.nmapkey("e", function() + require("neo-tree.command").execute({ + position = "left", + action = "toggle", + }) + end, "Toggle Neotree", opts) + utils.nmapkey("ee", function() require("neo-tree.command").execute({ position = "left", focus = "true", }) - end, { desc = "Focus (Neotree)", noremap = true, silent = true }) - keymap.set("n", "ee", function() - require("neo-tree.command").execute({ - position = "left", - focus = "true", - }) - end, { desc = "Focus (Neotree)", noremap = true, silent = true }) - keymap.set("n", "qe", function() + end, "Open Neotree", opts) + utils.nmapkey("qe", function() require("neo-tree.command").execute({ position = "left", action = "close", focus = "true", }) - end, { desc = "Close (Neotree)", noremap = true, silent = true }) + end, "Close Neotree", opts) - keymap.set("n", "|", "Neotree reveal", { desc = "", noremap = true, silent = true }) - keymap.set( - "n", - "gd", - "Neotree float reveal_file= reveal_force_cwd", - { desc = "", noremap = true, silent = true } - ) - keymap.set( - "n", + utils.mapkey({ "n", "v" }, "|", "Neotree reveal", "Reveal file in Neotree", opts) + utils.nmapkey( "eb", "Neotree toggle show buffers right", - { desc = "Show buffers (Neotree)", noremap = true, silent = true } + "Show buffers (Neotree)", + { noremap = true, silent = true } ) - keymap.set( - "n", + utils.nmapkey( "gs", "Neotree float git_status", - { desc = "Show git status (Neotree)", noremap = true, silent = true } + "Show git status (Neotree)", + { noremap = true, silent = true } ) end, }, diff --git a/.config/nvim/lua/plugins/language_support/conform.lua b/.config/nvim/lua/plugins/language_support/conform.lua index f21b2e8..30a0f36 100644 --- a/.config/nvim/lua/plugins/language_support/conform.lua +++ b/.config/nvim/lua/plugins/language_support/conform.lua @@ -14,7 +14,7 @@ return { end local function decide_js_formatter() local cwd = vim.fn.getcwd() - if file_exists(cwd .. "/biome.json") then + if file_exists(cwd .. "/biome.json") or file_exists(cwd .. "/biome.jsonc") then return "biome" else return "prettier" @@ -22,7 +22,7 @@ return { end local function decide_json_formatter() local cwd = vim.fn.getcwd() - if file_exists(cwd .. "/biome.json") then + if file_exists(cwd .. "/biome.json") or file_exists(cwd .. "/biome.jsonc") then return "biome" elseif file_exists(cwd .. "/.prettierrc") then return "prettier" @@ -41,7 +41,7 @@ return { lua = { "stylua" }, markdown = { "mdformat" }, nginx = { "nginxfmt" }, - python = { "isort", "black" }, + python = { "isort", "autopep8", "black" }, sh = { "shfmt" }, sql = { "sql_formatter" }, typescript = { decide_js_formatter() }, @@ -72,11 +72,8 @@ return { lsp_format = "fallback", timeout_ms = 500, }, - -- Set the log level. Use `:ConformInfo` to see the location of the log file. log_level = vim.log.levels.ERROR, - -- Conform will notify you when a formatter errors notify_on_error = true, - -- Conform will notify you when no formatters are available for the buffer notify_no_formatters = true, }) end, diff --git a/.config/nvim/lua/plugins/language_support/nvim-lint.lua b/.config/nvim/lua/plugins/language_support/nvim-lint.lua index 8e2a5dd..e863d0f 100644 --- a/.config/nvim/lua/plugins/language_support/nvim-lint.lua +++ b/.config/nvim/lua/plugins/language_support/nvim-lint.lua @@ -1,3 +1,5 @@ +local utils = require("utils") + return { "mfussenegger/nvim-lint", config = function() @@ -10,9 +12,9 @@ return { return false end end - local function decide_linter() + local function decide_js_linter() local cwd = vim.fn.getcwd() - if file_exists(cwd .. "/biome.json") then + if file_exists(cwd .. "/biome.json") or file_exists(cwd .. "/biome.jsonc") then return "biomejs" else return "eslint_d" @@ -22,17 +24,16 @@ return { local lint = require("lint") lint.linters_by_ft = { - javascript = { decide_linter() }, - javascriptreact = { decide_linter() }, + javascript = { decide_js_linter() }, + javascriptreact = { decide_js_linter() }, markdown = { "markdownlint" }, python = { "flake8" }, sh = { "shellcheck" }, - typescript = { decide_linter() }, - typescriptreact = { decide_linter() }, + typescript = { decide_js_linter() }, + typescriptreact = { decide_js_linter() }, } local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) - vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { group = lint_augroup, callback = function() @@ -40,8 +41,8 @@ return { end, }) - vim.keymap.set("n", "l", function() + utils.nmapkey("l", function() lint.try_lint() - end, { desc = "Trigger linting for current file" }) + end, "Trigger linting for current file") end, } diff --git a/.config/nvim/lua/plugins/lsp/mason.lua b/.config/nvim/lua/plugins/lsp/mason.lua index 3caa7c8..0f7a13a 100644 --- a/.config/nvim/lua/plugins/lsp/mason.lua +++ b/.config/nvim/lua/plugins/lsp/mason.lua @@ -46,6 +46,7 @@ return { -- formatters, linters and debug adapters for mason to install require("mason-tool-installer").setup({ ensure_installed = { + "autopep8", "biome", "black", "checkstyle", diff --git a/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua b/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua index 48ad38d..b2348b9 100644 --- a/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua +++ b/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua @@ -1,3 +1,4 @@ +local utils = require("utils") return { "neovim/nvim-lspconfig", event = { "BufReadPre", "BufNewFile" }, @@ -19,55 +20,29 @@ return { }, }) -- - -- Create keymaps when using an LSP - local keymap = vim.keymap vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) local opts = { buffer = ev.buf, silent = true } + local telescope = require("telescope.builtin") - opts.desc = "Show LSP references" - keymap.set("n", "gR", "Telescope lsp_references", opts) -- show definition, references - - opts.desc = "Go to declaration" - keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration - - opts.desc = "Show LSP definitions" - keymap.set("n", "gd", "Telescope lsp_definitions", opts) -- show lsp definitions - - opts.desc = "Show LSP implementations" - keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations - - opts.desc = "Show LSP type definitions" - keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions - - opts.desc = "See available code actions" - keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection - - opts.desc = "Smart rename" - keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- smart rename - - opts.desc = "Show buffer diagnostics" - keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file - - opts.desc = "Show line diagnostics" - keymap.set("n", "d", vim.diagnostic.open_float, opts) -- show diagnostics for line - - opts.desc = "Go to previous diagnostic" - keymap.set("n", "[d", function() + utils.nmapkey("gR", telescope.lsp_references, "Show LSP references", opts) -- show definition, references + utils.nmapkey("gD", vim.lsp.buf.declaration, "Go to declaration", opts) -- go to declaration + utils.nmapkey("K", vim.lsp.buf.hover, "Show documentation for what is under cursor", opts) -- show documentation for what is under cursor + utils.nmapkey("gd", telescope.lsp_definitions, "Show LSP definitions", opts) + utils.nmapkey("gi", telescope.lsp_implementations, "Show LSP implementations", opts) + utils.nmapkey("gt", telescope.lsp_type_definitions, "Show LSP type definitions", opts) + utils.mapkey({ "n", "v" }, "ca", vim.lsp.buf.code_action, "See available code actions", opts) -- see available code actions + utils.nmapkey("rn", vim.lsp.buf.rename, "Smart rename", opts) -- smart rename + utils.nmapkey("D", telescope.diagnostics, "Show buffer diagnostics", opts) -- show diagnostics for file + utils.nmapkey("d", vim.diagnostic.open_float, "Show line diagnostics", opts) -- show diagnostics for line + utils.nmapkey("[d", function() vim.diagnostic.jump({ count = -1, float = true }) - end, opts) -- jump to previous diagnostic in buffer - - opts.desc = "Go to next diagnostic" - keymap.set("n", "]d", function() + end, "Go to previous diagnostic", opts) -- jump to previous diagnostic in buffer + utils.nmapkey("]d", function() vim.diagnostic.jump({ count = 1, float = true }) - end, opts) -- jump to next diagnostic in buffer - - opts.desc = "Show documentation for what is under cursor" - keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor - - opts.desc = "Restart LSP" - keymap.set("n", "rs", ":LspRestart", opts) -- mapping to restart lsp if necessary + end, "Go to next diagnostic", opts) -- jump to next diagnostic in buffer + utils.nmapkey("rs", "LspRestart", "Restart LSP", opts) -- mapping to restart lsp if necessary end, }) @@ -109,19 +84,15 @@ return { "${3rd}/luv/library", }, }, - -- Add the default completion capabilities capabilities = capabilities, }) end, - settings = { - Lua = {}, - }, }) -- ts_ls vim.lsp.config("ts_ls", { on_attach = function(client) - -- Disable formatting capability for tsserver + -- Disable formatting capability for tsserver (see conform.lua and nvim-lint.lua) client.server_capabilities.documentFormattingProvider = false client.server_capabilities.documentRangeFormattingProvider = false end, @@ -132,6 +103,7 @@ return { "typescriptreact", }, root_markers = { "tsconfig.json", "jsconfig.json", "package.json" }, + capabilities = capabilities, }) vim.lsp.config("jsonls", { @@ -143,9 +115,11 @@ return { filetypes = { "json", }, + capabilities = capabilities, }) vim.lsp.config("pylsp", { + settings = { pylsp = { plugins = { pycodestyle = { enabled = false } } } }, on_attach = function(client) client.server_capabilities.documentFormattingProvider = false client.server_capabilities.documentRangeFormattingProvider = false @@ -154,6 +128,7 @@ return { "python", }, root_markers = { "requirements.txt" }, + capabilities = capabilities, }) vim.lsp.config("bashls", { @@ -164,6 +139,7 @@ return { filetypes = { "sh", }, + capabilities = capabilities, }) end, } diff --git a/.config/nvim/lua/plugins/util/auto-session.lua b/.config/nvim/lua/plugins/util/auto-session.lua index 83edf16..7a4c73f 100644 --- a/.config/nvim/lua/plugins/util/auto-session.lua +++ b/.config/nvim/lua/plugins/util/auto-session.lua @@ -4,7 +4,7 @@ return { local auto_session = require("auto-session") auto_session.setup({ - auto_restore_enabled = false, + auto_restore_enabled = true, auto_session_suppress_dirs = { "~/", "~/Code/", "~/Downloads", "~/Documents", "~/Desktop/" }, }) @@ -16,6 +16,6 @@ return { "ws", "SessionSave", { desc = "Save session for auto session root dir (auto-session)" } - ) -- save workspace session for current working directory + ) end, } diff --git a/.zinit.zsh b/.zinit.zsh index a3dd561..dbde73f 100644 --- a/.zinit.zsh +++ b/.zinit.zsh @@ -46,23 +46,22 @@ zinit light Aloxaf/fzf-tab # AUTOSUGGESTIONS, TRIGGER PRECMD HOOK UPON LOAD ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 -zinit ice wait"0a" lucid atload"_zsh_autosuggest_start" +zinit ice wait"0a" lucid atload"_zsh_autosuggest_start;bindkey \"^[[A\" history-search-backward;bindkey \"^[[B\" history-search-forward" zinit light zsh-users/zsh-autosuggestions -# + # # ENHANCED -# zinit ice wait="0b" lucid -# zinit light b4b4r07/enhanced -# export ENHANCD_FILTER=fzf:fzy:peco +zinit ice wait="0b" lucid +zinit light b4b4r07/enhanced +export ENHANCD_FILTER=fzf:fzy:peco #SYNTAX HIGHLIGHTING zinit ice wait"0c" lucid atinit"zpcompinit;zpcdreplay" zinit light zdharma-continuum/fast-syntax-highlighting # ZOXIDE -zinit ice wait"0" lucid from"gh-r" as"program" pick"zoxide-*/zoxide -> zoxide" cp"zoxide-*/completions/_zoxide -> _zoxide" atclone"./zoxide init zsh > init.zsh" atpull"%atclone" src"init.zsh" +zinit ice wait"0a" lucid from"gh-r" as"program" pick"zoxide-*/zoxide -> zoxide" cp"zoxide-*/completions/_zoxide -> _zoxide" atclone"./zoxide init zsh > init.zsh" atpull"%atclone" src"init.zsh" zinit light ajeetdsouza/zoxide # TAB COMPLETIONS -# zinit ice wait="0b" lucid blockf -# zinit light zsh-users/zsh-completions - +zinit ice wait="0b" lucid blockf +zinit light zsh-users/zsh-completions diff --git a/.zstyle.zsh b/.zstyle.zsh index c42d8ca..3852d66 100644 --- a/.zstyle.zsh +++ b/.zstyle.zsh @@ -15,7 +15,6 @@ zstyle ':completion:*' completer _expand _complete _ignored _approximate zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # Disable the menu selection feature (automatically select the first match) -zstyle ':completion:*' menu select # Customize the prompt shown when scrolling through completions # - `%SScrolling active: current selection at %p%s`: Shows a message indicating that scrolling is active and the current selection. @@ -36,13 +35,9 @@ zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd # Disable sorting of completion options zstyle ':completion:complete:*:options' sort false -# Disable sorting of git checkout completions -zstyle ":completion:*:git-checkout:*" sort false - # Apply LS_COLORS to completion lists for colored output zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} -zstyle ':completion:*' menu select zstyle ':completion:*:matches' group 'yes' zstyle ':completion:*:options' description 'yes' zstyle ':completion:*:options' auto-description '%d' @@ -50,22 +45,22 @@ zstyle ':completion:*:corrections' format '%U%F{red}-- %d (errors: %e) --%f%u' zstyle ':completion:*:descriptions' format '%U%F{yellow}-- %d --%f%u' zstyle ':completion:*:messages' format '%F{purple} -- %d --%f' zstyle ':completion:*:warnings' format '%F{red} -- no matches found --%f' +# # Configure fzf-tab behavior -# -# # Use the input string as the query string for _zlua completions -# zstyle ':fzf-tab:complete:_zlua:*' query-string input -# -# # Customize the kill command completion with fzf-tab -# # - `extra-opts`: Additional options for fzf, including a preview window showing the command of the selected process. -# zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap -# -# # Customize the cd command completion with fzf-tab -# # - `fzf-preview`: Show a preview of directories using `eza` (a modern replacement for `ls`). -# zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' -# -# # Customize the z command completion with fzf-tab -# # - `fzf-preview`: Show a preview of directories using `eza`. -# zstyle ':fzf-tab:complete:z:*' fzf-preview 'eza -1 --color=always $realpath' -# -# # Use default fzf options for fzf-tab -# zstyle ':fzf-tab:*' use-fzf-default-opts yes +# Use the input string as the query string for _zlua completions +zstyle ':fzf-tab:complete:_zlua:*' query-string input + +# Customize the kill command completion with fzf-tab +# - `extra-opts`: Additional options for fzf, including a preview window showing the command of the selected process. +zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap + +# Customize the cd command completion with fzf-tab +# - `fzf-preview`: Show a preview of directories using `eza` (a modern replacement for `ls`). +zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' + +# Customize the z command completion with fzf-tab +# - `fzf-preview`: Show a preview of directories using `eza`. +zstyle ':fzf-tab:complete:z:*' fzf-preview 'eza -1 --color=always $realpath' + +# Use default fzf options for fzf-tab +zstyle ':fzf-tab:*' use-fzf-default-opts yes