🔧 Major overhaul of nvim config

This commit is contained in:
z3rOR0ne 2025-03-28 18:57:42 -07:00
parent 351ce052a7
commit 5e7afd99ec
38 changed files with 1091 additions and 87 deletions

View file

@ -0,0 +1,3 @@
require("nvim-autopairs").setup({
ignored_next_char = "[%w%\"]"
})

View file

@ -0,0 +1,6 @@
require'colorizer'.setup({
'*';
css = { css = true; };
html = { css = true; };
javascript = { css = true; };
})

View file

@ -0,0 +1,21 @@
function ColorMyPencils(color)
color = color or "nord"
vim.cmd.colorscheme(color)
-- vim.api.nvim_set_hl(0, "@attribute", { fg = "#B48EAD", italic = true }) -- For Tree-sitter
-- vim.api.nvim_set_hl(0, "@decorator", { fg = "#B48EAD", italic = true }) -- Some setups may use this
vim.api.nvim_set_hl(0, "TabLine", { bg = "none", fg = "#81A1C1" }) -- Inactive tabs
vim.api.nvim_set_hl(0, "TabLineSel", { bg = "none", fg = "#D8DEE9" }) -- Active tab
vim.api.nvim_set_hl(0, "TabLineFill", { bg = "none" }) -- Background area behind tabs
-- vim.api.nvim_set_hl(0, "DiagnosticVirtualTextError", { fg = "#BF616A", bg = "none" }) -- Nord red
-- vim.api.nvim_set_hl(0, "DiagnosticVirtualTextWarn", { fg = "#EBCB8B", bg = "none" }) -- Nord yellow
-- vim.api.nvim_set_hl(0, "DiagnosticVirtualTextInfo", { fg = "#B48EAD", bg = "none" }) -- Nord purple
-- vim.api.nvim_set_hl(0, "DiagnosticVirtualTextHint", { fg = "#81A1C1", bg = "none" }) -- Nord blue
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
end
ColorMyPencils()

View file

@ -0,0 +1,27 @@
require("conform").setup({
formatters_by_ft = {
python = { "isort", "black" },
lua = { "stylua" },
css = { "prettierd" },
javascript = { "prettierd", "prettier", stop_after_first = true },
typescript = { "prettierd", "prettier", stop_after_first = true },
javascriptreact = { "prettierd", "prettier", stop_after_first = true },
typescriptreact = { "prettierd", "prettier", stop_after_first = true },
html = { "prettierd", "prettier", stop_after_first = true },
pug = { "prettierd", "prettier", stop_after_first = true },
vue = { "prettierd", "prettier", stop_after_first = true },
sql = { "sql_formatter" },
rust = { "rustfmt" },
golang = { "gofmt" },
sh = { "shfmt" },
json = { "jq", "deno_fmt", stop_after_first = true },
toml = { "taplo" },
yaml = { "yq" },
markdown = { "deno_fmt" },
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_format = "fallback",
},
})

View file

@ -0,0 +1 @@
require("crates").setup()

View file

@ -0,0 +1,31 @@
require("dap-vscode-js").setup({
adapaters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" },
})
local languages = { "typescript", "javascript" }
for _, language in ipairs(languages) do
require("dap").configurations[language] = {
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "attach",
name = "Attach",
processId = require("dap.utils").pick_process,
cwd = "${workspaceFolder}",
},
{
type = "pwa-chrome",
request = "launch",
name = 'Start Chrome with "localhost"',
url = "http://localhost:3000",
webRoot = "${workspaceFolder}",
userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir",
},
}
end

View file

@ -0,0 +1,13 @@
require("dapui").setup()
local dap, dapui = require("dap"), require("dapui")
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

View file

@ -0,0 +1,3 @@
require("gitblame").setup({
enabled = false,
})

View file

@ -0,0 +1,14 @@
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-o>", ui.toggle_quick_menu)
vim.keymap.set("n", "<leader>j", function() ui.nav_file(1) end)
vim.keymap.set("n", "<leader>k", function() ui.nav_file(2) end)
vim.keymap.set("n", "<leader>l", function() ui.nav_file(3) end)
vim.keymap.set("n", "<leader>;", function() ui.nav_file(4) end)
vim.keymap.set("n", "<leader>m", function() ui.nav_file(5) end)
vim.keymap.set("n", "<leader>,", function() ui.nav_file(6) end)
vim.keymap.set("n", "<leader>.", function() ui.nav_file(7) end)
vim.keymap.set("n", "<leader>/", function() ui.nav_file(8) end)

View file

@ -0,0 +1,3 @@
require("ibl").setup({
indent = { char = "¦" },
})

View file

@ -0,0 +1,117 @@
local lsp = require("lsp-zero")
local lspconfig = require("lspconfig")
local cmp = require("cmp")
lsp.preset("recommended")
require("mason").setup()
lsp.ensure_installed({
"bashls",
"biome",
"clangd",
"cssls",
"dockerls",
"emmet_ls",
"eslint",
"html",
"lua_ls",
"quick_lint_js",
"rust_analyzer",
"svelte",
"ts_ls",
"volar",
"zls",
})
cmp.setup({
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
})
lsp.set_preferences({
suggest_lsp_servers = false,
sign_icons = {
error = "E",
warn = "W",
hint = "H",
info = "I",
},
})
-- function that is used with keybinding cm to toggle autocompletion
Mode = require("cmp.types").cmp.TriggerEvent.TextChanged
function SetAutoCmp(mode)
if mode then
cmp.setup({
completion = {
autocomplete = { Mode },
},
})
Mode = false
else
cmp.setup({
completion = {
autocomplete = Mode,
},
})
Mode = require("cmp.types").cmp.TriggerEvent.TextChanged
end
end
SetAutoCmp(Mode)
lsp.setup()
-- configure diagnostic lsp err msgs
vim.diagnostic.config({
underline = true,
virtual_text = true,
float = {
source = "always",
focusable = false,
},
})
-- toggles floating error messages
vim.keymap.set("n", "<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>")
-- LSP Specific Settings
-- Volar TypeScript Config (turn off for Vue with Vanilla JS)
require("mason-lspconfig").setup_handlers({
function(server_name)
local server_config = {}
if server_name == "volar" then
server_config.filetypes = { "vue", "ts_ls", "javascript" }
lspconfig.volar.setup({
settings = {
["volar.takeOverMode.enabled"] = true,
},
})
end
lspconfig.rust_analyzer.setup({
settings = {
["rust-analyzer"] = {
procMacro = {
ignored = {
leptos_macro = {
"server",
},
},
},
rustfmt = {
overrideCommand = {
"leptosfmt",
"--stdin",
"--rustfmt",
},
edition = { "2021" },
},
cargo = {
allFeatures = true,
},
},
},
})
lspconfig[server_name].setup(server_config)
end,
})

View file

@ -0,0 +1,12 @@
local function show_codeium_status()
return "{…}" .. vim.fn["codeium#GetStatusString"]()
end
require("lualine").setup({
options = { theme = "nord" },
sections = {
lualine_x = {
{ show_codeium_status },
},
},
})

View file

@ -0,0 +1,2 @@
vim.g.mkdp_browser = "librewolf"
vim.g.mkdp_theme = "dark"

View file

@ -0,0 +1 @@
vim.opt.cursorcolumn = true

View file

@ -0,0 +1,6 @@
-- Create Default Mappings for NerdCommenter
vim.g.NERDCreateDefaultMappings = 1
-- Add spaces after NerdCommenter delimiters by default
vim.g.NERDSpaceDelims = 1
-- Enable Comments with Italics
-- vim.cmd[[highlight Comment cterm=italic gui=italic]]

View file

@ -0,0 +1,32 @@
local null_ls = require("null-ls")
local group = vim.api.nvim_create_augroup("lsp_format_on_save", { clear = false })
local event = "BufWritePre" -- or "BufWritePost"
local async = event == "BufWritePost"
null_ls.setup({
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.keymap.set("n", "<Leader>f", function()
vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() })
end, { buffer = bufnr, desc = "[lsp] format" })
-- format on save
vim.api.nvim_clear_autocmds({ buffer = bufnr, group = group })
vim.api.nvim_create_autocmd(event, {
buffer = bufnr,
group = group,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr, async = async })
end,
desc = "[lsp] format on save",
})
end
if client.supports_method("textDocument/rangeFormatting") then
vim.keymap.set("x", "<Leader>f", function()
vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() })
end, { buffer = bufnr, desc = "[lsp] format" })
end
end,
})

View file

@ -0,0 +1,113 @@
-- Nvim_Tree configuration: -- setup with all defaults
-- each of these are documented in `:help nvim-tree.OPTION_NAME`
require("nvim-tree").setup({ -- BEGIN_DEFAULT_OPTS
auto_reload_on_write = true,
disable_netrw = false,
-- hide_root_folder = false,
hijack_cursor = false,
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false,
open_on_tab = false,
sort_by = "name",
update_cwd = false,
view = {
width = 25,
-- height = 30,
side = "right",
preserve_window_proportions = true,
number = false,
relativenumber = false,
signcolumn = "yes",
-- mappings = {
-- custom_only = false,
-- list = {
-- user mappings go here
-- },
-- },
},
renderer = {
indent_markers = {
enable = false,
icons = {
corner = "",
edge = "",
none = " ",
},
},
icons = {
webdev_colors = true,
},
},
hijack_directories = {
enable = true,
auto_open = true,
},
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {},
},
system_open = {
cmd = nil,
args = {},
},
diagnostics = {
enable = false,
show_on_dirs = false,
icons = {
hint = "",
info = "",
warning = "",
error = "",
},
},
filters = {
dotfiles = false,
custom = {},
exclude = {},
},
git = {
enable = true,
ignore = true,
timeout = 400,
},
actions = {
use_system_clipboard = true,
change_dir = {
enable = true,
global = false,
restrict_above_cwd = false,
},
open_file = {
quit_on_open = false,
resize_window = false,
window_picker = {
enable = true,
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
},
},
},
},
trash = {
cmd = "trash",
require_confirm = true,
},
log = {
enable = false,
truncate = false,
types = {
all = false,
config = false,
copy_paste = false,
diagnostics = false,
git = false,
profile = false,
},
},
}) -- END_DEFAULT_OPTS for Nvim_Tree
-- Automatically closes Nvim tree if last window open
vim.cmd([[autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif]])

View file

@ -0,0 +1 @@
vim.g.rainbow_active = 1

View file

@ -0,0 +1,12 @@
-- Enable use of ripgrep
require("nvim-ripgrep").setup({
runner = require("nvim-ripgrep.run").ripgrep, -- grep command
prompt = " ", -- prompt
window = {
width = 0.8,
border = "rounded",
},
open_qf_fn = function()
return vim.api.nvim_command("copen")
end,
})

View file

@ -0,0 +1,10 @@
require("telescope").setup({
extensions = {
undo = {
layout_strategy = "vertical",
layout_config = {
preview_height = 0.8,
},
},
},
})

View file

@ -0,0 +1,57 @@
vim.treesitter.query.set("javascript", "injections", "")
vim.treesitter.query.set("typescript", "injections", "")
vim.treesitter.query.set("tsx", "injections", "")
vim.treesitter.query.set("lua", "injections", "")
require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all"
ensure_installed = {
"bash",
"c",
"c_sharp",
"cmake",
"cpp",
"css",
"dockerfile",
"go",
"html",
"http",
"java",
"javascript",
"json",
"json5",
"jsonc",
"lua",
"make",
"perl",
"php",
"pug",
"python",
"ruby",
"toml",
"tsx",
"typescript",
"rust",
"vim",
"vue",
"yaml",
"zig",
},
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
highlight = {
-- `false` will disable the whole extension
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
})

View file

@ -0,0 +1,2 @@
vim.g.undotree_DiffAutoOpen = 0
vim.g.undotree_SetFocusWhenToggle = 1

View file

@ -0,0 +1,2 @@
-- Use experimental features of vim-smoothie (gg and G)
vim.g.smoothie_experimental_mappings = 1