Update zinit and nvim

This commit is contained in:
ItaloBorrelli 2025-09-09 11:36:52 -07:00
parent a43e2f2126
commit d620f21291
8 changed files with 84 additions and 119 deletions

View File

@ -1,3 +1,4 @@
local utils = require("utils")
return { return {
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
@ -22,44 +23,39 @@ return {
}) })
local keymap = vim.keymap local keymap = vim.keymap
keymap.set("n", "<leader>e", function() local opts = { noremap = true, silent = true }
utils.nmapkey("<leader>e", function()
require("neo-tree.command").execute({
position = "left",
action = "toggle",
})
end, "Toggle Neotree", opts)
utils.nmapkey("<leader>ee", function()
require("neo-tree.command").execute({ require("neo-tree.command").execute({
position = "left", position = "left",
focus = "true", focus = "true",
}) })
end, { desc = "Focus (Neotree)", noremap = true, silent = true }) end, "Open Neotree", opts)
keymap.set("n", "<leader>ee", function() utils.nmapkey("<leader>qe", function()
require("neo-tree.command").execute({
position = "left",
focus = "true",
})
end, { desc = "Focus (Neotree)", noremap = true, silent = true })
keymap.set("n", "<leader>qe", function()
require("neo-tree.command").execute({ require("neo-tree.command").execute({
position = "left", position = "left",
action = "close", action = "close",
focus = "true", focus = "true",
}) })
end, { desc = "Close (Neotree)", noremap = true, silent = true }) end, "Close Neotree", opts)
keymap.set("n", "|", "<cmd>Neotree reveal<cr>", { desc = "", noremap = true, silent = true }) utils.mapkey({ "n", "v" }, "|", "<cmd>Neotree reveal<cr>", "Reveal file in Neotree", opts)
keymap.set( utils.nmapkey(
"n",
"gd",
"<cmd>Neotree float reveal_file=<cfile> reveal_force_cwd<cr>",
{ desc = "", noremap = true, silent = true }
)
keymap.set(
"n",
"<leader>eb", "<leader>eb",
"<cmd>Neotree toggle show buffers right<cr>", "<cmd>Neotree toggle show buffers right<cr>",
{ desc = "Show buffers (Neotree)", noremap = true, silent = true } "Show buffers (Neotree)",
{ noremap = true, silent = true }
) )
keymap.set( utils.nmapkey(
"n",
"<leader>gs", "<leader>gs",
"<cmd>Neotree float git_status<cr>", "<cmd>Neotree float git_status<cr>",
{ desc = "Show git status (Neotree)", noremap = true, silent = true } "Show git status (Neotree)",
{ noremap = true, silent = true }
) )
end, end,
}, },

View File

@ -14,7 +14,7 @@ return {
end end
local function decide_js_formatter() local function decide_js_formatter()
local cwd = vim.fn.getcwd() 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" return "biome"
else else
return "prettier" return "prettier"
@ -22,7 +22,7 @@ return {
end end
local function decide_json_formatter() local function decide_json_formatter()
local cwd = vim.fn.getcwd() 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" return "biome"
elseif file_exists(cwd .. "/.prettierrc") then elseif file_exists(cwd .. "/.prettierrc") then
return "prettier" return "prettier"
@ -41,7 +41,7 @@ return {
lua = { "stylua" }, lua = { "stylua" },
markdown = { "mdformat" }, markdown = { "mdformat" },
nginx = { "nginxfmt" }, nginx = { "nginxfmt" },
python = { "isort", "black" }, python = { "isort", "autopep8", "black" },
sh = { "shfmt" }, sh = { "shfmt" },
sql = { "sql_formatter" }, sql = { "sql_formatter" },
typescript = { decide_js_formatter() }, typescript = { decide_js_formatter() },
@ -72,11 +72,8 @@ return {
lsp_format = "fallback", lsp_format = "fallback",
timeout_ms = 500, timeout_ms = 500,
}, },
-- Set the log level. Use `:ConformInfo` to see the location of the log file.
log_level = vim.log.levels.ERROR, log_level = vim.log.levels.ERROR,
-- Conform will notify you when a formatter errors
notify_on_error = true, notify_on_error = true,
-- Conform will notify you when no formatters are available for the buffer
notify_no_formatters = true, notify_no_formatters = true,
}) })
end, end,

View File

@ -1,3 +1,5 @@
local utils = require("utils")
return { return {
"mfussenegger/nvim-lint", "mfussenegger/nvim-lint",
config = function() config = function()
@ -10,9 +12,9 @@ return {
return false return false
end end
end end
local function decide_linter() local function decide_js_linter()
local cwd = vim.fn.getcwd() 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" return "biomejs"
else else
return "eslint_d" return "eslint_d"
@ -22,17 +24,16 @@ return {
local lint = require("lint") local lint = require("lint")
lint.linters_by_ft = { lint.linters_by_ft = {
javascript = { decide_linter() }, javascript = { decide_js_linter() },
javascriptreact = { decide_linter() }, javascriptreact = { decide_js_linter() },
markdown = { "markdownlint" }, markdown = { "markdownlint" },
python = { "flake8" }, python = { "flake8" },
sh = { "shellcheck" }, sh = { "shellcheck" },
typescript = { decide_linter() }, typescript = { decide_js_linter() },
typescriptreact = { decide_linter() }, typescriptreact = { decide_js_linter() },
} }
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup, group = lint_augroup,
callback = function() callback = function()
@ -40,8 +41,8 @@ return {
end, end,
}) })
vim.keymap.set("n", "<leader>l", function() utils.nmapkey("<leader>l", function()
lint.try_lint() lint.try_lint()
end, { desc = "Trigger linting for current file" }) end, "Trigger linting for current file")
end, end,
} }

View File

@ -46,6 +46,7 @@ return {
-- formatters, linters and debug adapters for mason to install -- formatters, linters and debug adapters for mason to install
require("mason-tool-installer").setup({ require("mason-tool-installer").setup({
ensure_installed = { ensure_installed = {
"autopep8",
"biome", "biome",
"black", "black",
"checkstyle", "checkstyle",

View File

@ -1,3 +1,4 @@
local utils = require("utils")
return { return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" }, event = { "BufReadPre", "BufNewFile" },
@ -19,55 +20,29 @@ return {
}, },
}) })
-- --
-- Create keymaps when using an LSP
local keymap = vim.keymap
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}), group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev) callback = function(ev)
local opts = { buffer = ev.buf, silent = true } local opts = { buffer = ev.buf, silent = true }
local telescope = require("telescope.builtin")
opts.desc = "Show LSP references" utils.nmapkey("gR", telescope.lsp_references, "Show LSP references", opts) -- show definition, references
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", 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
opts.desc = "Go to declaration" utils.nmapkey("gd", telescope.lsp_definitions, "Show LSP definitions", opts)
keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration utils.nmapkey("gi", telescope.lsp_implementations, "Show LSP implementations", opts)
utils.nmapkey("gt", telescope.lsp_type_definitions, "Show LSP type definitions", opts)
opts.desc = "Show LSP definitions" utils.mapkey({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, "See available code actions", opts) -- see available code actions
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions utils.nmapkey("<leader>rn", vim.lsp.buf.rename, "Smart rename", opts) -- smart rename
utils.nmapkey("<leader>D", telescope.diagnostics, "Show buffer diagnostics", opts) -- show diagnostics for file
opts.desc = "Show LSP implementations" utils.nmapkey("<leader>d", vim.diagnostic.open_float, "Show line diagnostics", opts) -- show diagnostics for line
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations utils.nmapkey("[d", function()
opts.desc = "Show LSP type definitions"
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
opts.desc = "See available code actions"
keymap.set({ "n", "v" }, "<leader>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", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
opts.desc = "Show buffer diagnostics"
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
opts.desc = "Show line diagnostics"
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
opts.desc = "Go to previous diagnostic"
keymap.set("n", "[d", function()
vim.diagnostic.jump({ count = -1, float = true }) vim.diagnostic.jump({ count = -1, float = true })
end, opts) -- jump to previous diagnostic in buffer end, "Go to previous diagnostic", opts) -- jump to previous diagnostic in buffer
utils.nmapkey("]d", function()
opts.desc = "Go to next diagnostic"
keymap.set("n", "]d", function()
vim.diagnostic.jump({ count = 1, float = true }) vim.diagnostic.jump({ count = 1, float = true })
end, opts) -- jump to next diagnostic in buffer end, "Go to next diagnostic", opts) -- jump to next diagnostic in buffer
utils.nmapkey("<leader>rs", "<cmd>LspRestart<cr>", "Restart LSP", opts) -- mapping to restart lsp if necessary
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", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
end, end,
}) })
@ -109,19 +84,15 @@ return {
"${3rd}/luv/library", "${3rd}/luv/library",
}, },
}, },
-- Add the default completion capabilities
capabilities = capabilities, capabilities = capabilities,
}) })
end, end,
settings = {
Lua = {},
},
}) })
-- ts_ls -- ts_ls
vim.lsp.config("ts_ls", { vim.lsp.config("ts_ls", {
on_attach = function(client) 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.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false client.server_capabilities.documentRangeFormattingProvider = false
end, end,
@ -132,6 +103,7 @@ return {
"typescriptreact", "typescriptreact",
}, },
root_markers = { "tsconfig.json", "jsconfig.json", "package.json" }, root_markers = { "tsconfig.json", "jsconfig.json", "package.json" },
capabilities = capabilities,
}) })
vim.lsp.config("jsonls", { vim.lsp.config("jsonls", {
@ -143,9 +115,11 @@ return {
filetypes = { filetypes = {
"json", "json",
}, },
capabilities = capabilities,
}) })
vim.lsp.config("pylsp", { vim.lsp.config("pylsp", {
settings = { pylsp = { plugins = { pycodestyle = { enabled = false } } } },
on_attach = function(client) on_attach = function(client)
client.server_capabilities.documentFormattingProvider = false client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false client.server_capabilities.documentRangeFormattingProvider = false
@ -154,6 +128,7 @@ return {
"python", "python",
}, },
root_markers = { "requirements.txt" }, root_markers = { "requirements.txt" },
capabilities = capabilities,
}) })
vim.lsp.config("bashls", { vim.lsp.config("bashls", {
@ -164,6 +139,7 @@ return {
filetypes = { filetypes = {
"sh", "sh",
}, },
capabilities = capabilities,
}) })
end, end,
} }

View File

@ -4,7 +4,7 @@ return {
local auto_session = require("auto-session") local auto_session = require("auto-session")
auto_session.setup({ auto_session.setup({
auto_restore_enabled = false, auto_restore_enabled = true,
auto_session_suppress_dirs = { "~/", "~/Code/", "~/Downloads", "~/Documents", "~/Desktop/" }, auto_session_suppress_dirs = { "~/", "~/Code/", "~/Downloads", "~/Documents", "~/Desktop/" },
}) })
@ -16,6 +16,6 @@ return {
"<leader>ws", "<leader>ws",
"<cmd>SessionSave<CR>", "<cmd>SessionSave<CR>",
{ desc = "Save session for auto session root dir (auto-session)" } { desc = "Save session for auto session root dir (auto-session)" }
) -- save workspace session for current working directory )
end, end,
} }

View File

@ -46,23 +46,22 @@ zinit light Aloxaf/fzf-tab
# AUTOSUGGESTIONS, TRIGGER PRECMD HOOK UPON LOAD # AUTOSUGGESTIONS, TRIGGER PRECMD HOOK UPON LOAD
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 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 zinit light zsh-users/zsh-autosuggestions
#
# # ENHANCED # # ENHANCED
# zinit ice wait="0b" lucid zinit ice wait="0b" lucid
# zinit light b4b4r07/enhanced zinit light b4b4r07/enhanced
# export ENHANCD_FILTER=fzf:fzy:peco export ENHANCD_FILTER=fzf:fzy:peco
#SYNTAX HIGHLIGHTING #SYNTAX HIGHLIGHTING
zinit ice wait"0c" lucid atinit"zpcompinit;zpcdreplay" zinit ice wait"0c" lucid atinit"zpcompinit;zpcdreplay"
zinit light zdharma-continuum/fast-syntax-highlighting zinit light zdharma-continuum/fast-syntax-highlighting
# ZOXIDE # 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 zinit light ajeetdsouza/zoxide
# TAB COMPLETIONS # TAB COMPLETIONS
# zinit ice wait="0b" lucid blockf zinit ice wait="0b" lucid blockf
# zinit light zsh-users/zsh-completions zinit light zsh-users/zsh-completions

View File

@ -15,7 +15,6 @@ zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# Disable the menu selection feature (automatically select the first match) # Disable the menu selection feature (automatically select the first match)
zstyle ':completion:*' menu select
# Customize the prompt shown when scrolling through completions # 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. # - `%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 # Disable sorting of completion options
zstyle ':completion:complete:*:options' sort false 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 # Apply LS_COLORS to completion lists for colored output
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' menu select
zstyle ':completion:*:matches' group 'yes' zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*:options' description 'yes' zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d' 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:*:descriptions' format '%U%F{yellow}-- %d --%f%u'
zstyle ':completion:*:messages' format '%F{purple} -- %d --%f' zstyle ':completion:*:messages' format '%F{purple} -- %d --%f'
zstyle ':completion:*:warnings' format '%F{red} -- no matches found --%f' zstyle ':completion:*:warnings' format '%F{red} -- no matches found --%f'
#
# Configure fzf-tab behavior # Configure fzf-tab behavior
# # Use the input string as the query string for _zlua completions
# # Use the input string as the query string for _zlua completions zstyle ':fzf-tab:complete:_zlua:*' query-string input
# zstyle ':fzf-tab:complete:_zlua:*' query-string input
# # Customize the kill command completion with fzf-tab
# # 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.
# # - `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
# 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
# # Customize the cd command completion with fzf-tab # - `fzf-preview`: Show a preview of directories using `eza` (a modern replacement for `ls`).
# # - `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'
# zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
# # Customize the z command completion with fzf-tab
# # Customize the z command completion with fzf-tab # - `fzf-preview`: Show a preview of directories using `eza`.
# # - `fzf-preview`: Show a preview of directories using `eza`. zstyle ':fzf-tab:complete:z:*' fzf-preview 'eza -1 --color=always $realpath'
# zstyle ':fzf-tab:complete:z:*' fzf-preview 'eza -1 --color=always $realpath'
# # Use default fzf options for fzf-tab
# # Use default fzf options for fzf-tab zstyle ':fzf-tab:*' use-fzf-default-opts yes
# zstyle ':fzf-tab:*' use-fzf-default-opts yes