From 157d52a23e0dd154a5938ebc93cea9fd7b5e2e29 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Tue, 12 Aug 2025 15:52:06 +0930 Subject: [PATCH] feat: updates --- .config/alacritty/alacritty.toml | 4 +- .config/alacritty/carbonfox.toml | 79 +++++ .config/hypr/hyprland.conf | 4 +- .config/nvim/lua/core/remaps.lua | 16 -- .config/nvim/lua/lsp/servers/clangd.lua | 31 ++ .config/nvim/lua/lsp/servers/cssls.lua | 1 + .config/nvim/lua/lsp/servers/gopls.lua | 18 ++ .config/nvim/lua/lsp/servers/html.lua | 3 + .config/nvim/lua/lsp/servers/intelephense.lua | 86 ++++++ .config/nvim/lua/lsp/servers/jsonls.lua | 10 + .../lsp/servers/kotlin_language_server.lua | 11 + .config/nvim/lua/lsp/servers/lua_ls.lua | 22 ++ .config/nvim/lua/lsp/servers/pyright.lua | 51 ++++ .../nvim/lua/lsp/servers/rust_analyzer.lua | 21 ++ .config/nvim/lua/lsp/servers/ts_ls.lua | 75 +++++ .config/nvim/lua/lsp/servers/yamlls.lua | 14 + .config/nvim/lua/lsp/utils.lua | 78 +++++ .config/nvim/lua/plugins/alpha.lua | 44 --- .config/nvim/lua/plugins/avante.lua | 55 ---- .config/nvim/lua/plugins/blink.lua | 50 +++- .config/nvim/lua/plugins/claude-code.lua | 11 + .config/nvim/lua/plugins/colorscheme.lua | 9 + .config/nvim/lua/plugins/fugitive.lua | 167 +++++++++-- .config/nvim/lua/plugins/lspconfig.lua | 269 +++--------------- .config/nvim/lua/plugins/lualine.lua | 86 ++++-- .config/nvim/lua/plugins/neotest.lua | 16 +- .config/nvim/lua/plugins/nvim-go.lua | 2 +- .config/nvim/lua/plugins/refactor.lua | 9 - .config/nvim/lua/plugins/telescope.lua | 214 ++++++++------ .../nvim/lua/plugins/telescope/multigrep.lua | 4 +- .config/nvim/lua/plugins/typr.lua | 6 - .config/zsh/.zprofile | 6 - .profile | 1 + .tmux.conf | 35 ++- 34 files changed, 969 insertions(+), 539 deletions(-) create mode 100644 .config/alacritty/carbonfox.toml create mode 100644 .config/nvim/lua/lsp/servers/clangd.lua create mode 100644 .config/nvim/lua/lsp/servers/cssls.lua create mode 100644 .config/nvim/lua/lsp/servers/gopls.lua create mode 100644 .config/nvim/lua/lsp/servers/html.lua create mode 100644 .config/nvim/lua/lsp/servers/intelephense.lua create mode 100644 .config/nvim/lua/lsp/servers/jsonls.lua create mode 100644 .config/nvim/lua/lsp/servers/kotlin_language_server.lua create mode 100644 .config/nvim/lua/lsp/servers/lua_ls.lua create mode 100644 .config/nvim/lua/lsp/servers/pyright.lua create mode 100644 .config/nvim/lua/lsp/servers/rust_analyzer.lua create mode 100644 .config/nvim/lua/lsp/servers/ts_ls.lua create mode 100644 .config/nvim/lua/lsp/servers/yamlls.lua create mode 100644 .config/nvim/lua/lsp/utils.lua delete mode 100644 .config/nvim/lua/plugins/alpha.lua delete mode 100644 .config/nvim/lua/plugins/avante.lua create mode 100644 .config/nvim/lua/plugins/claude-code.lua delete mode 100644 .config/nvim/lua/plugins/refactor.lua delete mode 100644 .config/nvim/lua/plugins/typr.lua delete mode 100644 .config/zsh/.zprofile diff --git a/.config/alacritty/alacritty.toml b/.config/alacritty/alacritty.toml index 062fd39..2459caf 100644 --- a/.config/alacritty/alacritty.toml +++ b/.config/alacritty/alacritty.toml @@ -1,8 +1,8 @@ [general] -import = ["~/.config/alacritty/cyberdream.toml"] +import = ["~/.config/alacritty/carbonfox.toml"] [window] -opacity = 0.90 +opacity = 1 [font] size = 10.0 diff --git a/.config/alacritty/carbonfox.toml b/.config/alacritty/carbonfox.toml new file mode 100644 index 0000000..f98a5b9 --- /dev/null +++ b/.config/alacritty/carbonfox.toml @@ -0,0 +1,79 @@ +# Nightfox Alacritty Colors +## name: carbonfox +## upstream: https://github.com/edeneast/nightfox.nvim/raw/main/extra/carbonfox/alacritty.toml + +[colors.primary] +background = "#161616" +foreground = "#f2f4f8" +dim_foreground = "#b6b8bb" +bright_foreground = "#f9fbff" + +[colors.cursor] +text = "#f2f4f8" +cursor = "#b6b8bb" + +[colors.vi_mode_cursor] +text = "#f2f4f8" +cursor = "#33b1ff" + +[colors.search.matches] +foreground = "#f2f4f8" +background = "#525253" + +[colors.search.focused_match] +foreground = "#f2f4f8" +background = "#3ddbd9" + +[colors.footer_bar] +foreground = "#f2f4f8" +background = "#353535" + +[colors.hints.start] +foreground = "#f2f4f8" +background = "#3ddbd9" + +[colors.hints.end] +foreground = "#f2f4f8" +background = "#353535" + +[colors.selection] +text = "#f2f4f8" +background = "#2a2a2a" + +[colors.normal] +black = "#282828" +red = "#ee5396" +green = "#25be6a" +yellow = "#08bdba" +blue = "#78a9ff" +magenta = "#be95ff" +cyan = "#33b1ff" +white = "#dfdfe0" + +[colors.bright] +black = "#484848" +red = "#f16da6" +green = "#46c880" +yellow = "#2dc7c4" +blue = "#8cb6ff" +magenta = "#c8a5ff" +cyan = "#52bdff" +white = "#e4e4e5" + +[colors.dim] +black = "#222222" +red = "#ca4780" +green = "#1fa25a" +yellow = "#07a19e" +blue = "#6690d9" +magenta = "#a27fd9" +cyan = "#2b96d9" +white = "#bebebe" + +[[colors.indexed_colors]] +index = 16 +color = "#3ddbd9" + +[[colors.indexed_colors]] +index = 17 +color = "#ff7eb6" diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index 2a6c1c5..a732040 100644 --- a/.config/hypr/hyprland.conf +++ b/.config/hypr/hyprland.conf @@ -139,8 +139,8 @@ input { kb_layout = us kb_variant = kb_model = - # kb_options = kb_options = caps:swapescape - kb_options = = + kb_options = kb_options = caps:swapescape + # kb_options = = kb_rules = follow_mouse = 1 diff --git a/.config/nvim/lua/core/remaps.lua b/.config/nvim/lua/core/remaps.lua index 9c96933..a106857 100644 --- a/.config/nvim/lua/core/remaps.lua +++ b/.config/nvim/lua/core/remaps.lua @@ -35,22 +35,6 @@ vim.keymap.set("v", "d", '"_d', { desc = "Delete into black hole registe vim.keymap.set("n", "", "zz", { desc = "Scroll down half page" }) vim.keymap.set("n", "", "zz", { desc = "Scroll up half page" }) --- -- Keep cursor centered --- vim.keymap.set("n", "n", function() --- if vim.bo.filetype == "fugitive" then --- return "n" --- else --- return "nzzzv" --- end --- end, { desc = "Next search result" }) --- vim.keymap.set("n", "N", function() --- if vim.bo.filetype == "fugitive" then --- return "N" --- else --- return "Nzzzv" --- end --- end, { desc = "Previous search result" }) --- -- Keep cursor centered when jumping through quickfix list vim.keymap.set("n", "N", "cprevzz", { desc = "Previous item in quickfix list" }) vim.keymap.set("n", "n", "cnextzz", { desc = "Next item in quickfix list" }) diff --git a/.config/nvim/lua/lsp/servers/clangd.lua b/.config/nvim/lua/lsp/servers/clangd.lua new file mode 100644 index 0000000..a5ce399 --- /dev/null +++ b/.config/nvim/lua/lsp/servers/clangd.lua @@ -0,0 +1,31 @@ +local util = require("lspconfig.util") + +return { + cmd = { + "clangd", + "--compile-commands-dir=.", + "--header-insertion=never", + "--cross-file-rename", + "--clang-tidy", + "--completion-style=detailed", + "--function-arg-placeholders", + "--fallback-style=llvm", + }, + filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" }, + root_dir = util.root_pattern( + '.clangd', + '.clang-tidy', + '.clang-format', + 'compile_commands.json', + 'compile_flags.txt', + 'configure.in', + '.git', + 'Makefile' + ), + single_file_support = true, + init_options = { + usePlaceholders = true, + completeUnimported = true, + clangdFileStatus = true, + }, +} diff --git a/.config/nvim/lua/lsp/servers/cssls.lua b/.config/nvim/lua/lsp/servers/cssls.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/.config/nvim/lua/lsp/servers/cssls.lua @@ -0,0 +1 @@ +return {} diff --git a/.config/nvim/lua/lsp/servers/gopls.lua b/.config/nvim/lua/lsp/servers/gopls.lua new file mode 100644 index 0000000..955c189 --- /dev/null +++ b/.config/nvim/lua/lsp/servers/gopls.lua @@ -0,0 +1,18 @@ +local util = require("lspconfig.util") + +return { + cmd = { "gopls" }, + filetypes = { "go", "gomod", "gowork", "gotmpl" }, + root_dir = util.root_pattern("go.work", "go.mod", ".git"), + settings = { + gopls = { + completeUnimported = true, + usePlaceholders = true, + analyses = { + unusedparams = true, + }, + staticcheck = true, + gofumpt = true, + }, + }, +} diff --git a/.config/nvim/lua/lsp/servers/html.lua b/.config/nvim/lua/lsp/servers/html.lua new file mode 100644 index 0000000..9f4ba03 --- /dev/null +++ b/.config/nvim/lua/lsp/servers/html.lua @@ -0,0 +1,3 @@ +return { + filetypes = { "html", "templ" }, +} diff --git a/.config/nvim/lua/lsp/servers/intelephense.lua b/.config/nvim/lua/lsp/servers/intelephense.lua new file mode 100644 index 0000000..24e5f1b --- /dev/null +++ b/.config/nvim/lua/lsp/servers/intelephense.lua @@ -0,0 +1,86 @@ +local util = require("lspconfig.util") +local utils = require("lsp.utils") + +-- Only setup if license file exists +local license_path = vim.fn.expand("$HOME/.local/share/nvim/intelephense-licence.txt") +if not utils.file_exists(license_path) then + vim.notify("Intelephense license not found at: " .. license_path, vim.log.levels.WARN) +end + +return { + root_dir = function(pattern) + local root = util.root_pattern("composer.json", "composer.lock")(pattern) + return root or vim.fn.getcwd() + end, + single_file_support = false, + init_options = { + licenceKey = license_path, + }, + settings = { + intelephense = { + format = { + enable = true, + sortUseStatements = true, + }, + stubs = { + "bcmath", + "bz2", + "calendar", + "Core", + "curl", + "date", + "dba", + "dom", + "enchant", + "fileinfo", + "filter", + "ftp", + "gd", + "gettext", + "hash", + "iconv", + "imap", + "intl", + "json", + "libxml", + "mbstring", + "mcrypt", + "mysql", + "mysqli", + "password", + "pcntl", + "pcre", + "PDO", + "pdo_mysql", + "Phar", + "readline", + "recode", + "Reflection", + "regex", + "session", + "SimpleXML", + "soap", + "sockets", + "sodium", + "SPL", + "standard", + "superglobals", + "sysvsem", + "sysvshm", + "tokenizer", + "xml", + "xdebug", + "xmlreader", + "xmlwriter", + "yaml", + "zip", + "zlib", + "wordpress", + "woocommerce", + "acf-pro", + "wordpress-globals", + "wp-cli", + }, + }, + }, +} diff --git a/.config/nvim/lua/lsp/servers/jsonls.lua b/.config/nvim/lua/lsp/servers/jsonls.lua new file mode 100644 index 0000000..096069e --- /dev/null +++ b/.config/nvim/lua/lsp/servers/jsonls.lua @@ -0,0 +1,10 @@ +return { + settings = { + json = { + validate = { enable = true }, + format = { + enable = true, + }, + }, + }, +} diff --git a/.config/nvim/lua/lsp/servers/kotlin_language_server.lua b/.config/nvim/lua/lsp/servers/kotlin_language_server.lua new file mode 100644 index 0000000..2cacf3c --- /dev/null +++ b/.config/nvim/lua/lsp/servers/kotlin_language_server.lua @@ -0,0 +1,11 @@ +return { + settings = { + kotlin = { + compiler = { + jvm = { + target = "1.8" + } + } + } + }, +} diff --git a/.config/nvim/lua/lsp/servers/lua_ls.lua b/.config/nvim/lua/lsp/servers/lua_ls.lua new file mode 100644 index 0000000..f67e88a --- /dev/null +++ b/.config/nvim/lua/lsp/servers/lua_ls.lua @@ -0,0 +1,22 @@ +return { + settings = { + Lua = { + -- Make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + workspace = { + -- Make language server aware of runtime files + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + -- Disable the luassert warning + checkThirdParty = false, + }, + telemetry = { + enable = false, + }, + }, + }, +} diff --git a/.config/nvim/lua/lsp/servers/pyright.lua b/.config/nvim/lua/lsp/servers/pyright.lua new file mode 100644 index 0000000..fda401f --- /dev/null +++ b/.config/nvim/lua/lsp/servers/pyright.lua @@ -0,0 +1,51 @@ +local util = require("lspconfig.util") + +-- Function to get python path (you can customize this) +local function get_python_path(workspace) + -- Check for virtual environment + if vim.env.VIRTUAL_ENV then + return vim.env.VIRTUAL_ENV .. "/bin/python" + end + + -- Check for poetry + if util.root_pattern("pyproject.toml")(workspace) then + local handle = io.popen("cd " .. workspace .. " && poetry env info --path 2>/dev/null") + if handle then + local poetry_venv = handle:read("*a"):gsub("\n", "") + handle:close() + if poetry_venv ~= "" then + return poetry_venv .. "/bin/python" + end + end + end + + -- Check for pipenv + if util.root_pattern("Pipfile")(workspace) then + local handle = io.popen("cd " .. workspace .. " && pipenv --venv 2>/dev/null") + if handle then + local pipenv_venv = handle:read("*a"):gsub("\n", "") + handle:close() + if pipenv_venv ~= "" then + return pipenv_venv .. "/bin/python" + end + end + end + + -- Default to system python + return "python3" +end + +return { + before_init = function(_, config) + config.settings.python.pythonPath = get_python_path(config.root_dir) + end, + settings = { + python = { + analysis = { + autoSearchPaths = true, + useLibraryCodeForTypes = true, + diagnosticMode = "workspace", + }, + }, + }, +} diff --git a/.config/nvim/lua/lsp/servers/rust_analyzer.lua b/.config/nvim/lua/lsp/servers/rust_analyzer.lua new file mode 100644 index 0000000..74ff715 --- /dev/null +++ b/.config/nvim/lua/lsp/servers/rust_analyzer.lua @@ -0,0 +1,21 @@ +return { + settings = { + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + }, + checkOnSave = { + command = "clippy", + }, + procMacro = { + enable = true, + }, + diagnostics = { + enable = true, + experimental = { + enable = true, + }, + }, + }, + }, +} diff --git a/.config/nvim/lua/lsp/servers/ts_ls.lua b/.config/nvim/lua/lsp/servers/ts_ls.lua new file mode 100644 index 0000000..a29c22b --- /dev/null +++ b/.config/nvim/lua/lsp/servers/ts_ls.lua @@ -0,0 +1,75 @@ +local util = require("lspconfig.util") +local utils = require("lsp.utils") + +-- Determine base path for node_modules +local base_path = utils.find_node_modules_path() + +if not base_path then + vim.notify("No global node_modules found for TypeScript server", vim.log.levels.WARN) + base_path = "" +end + +local function get_typescript_server_path(root_dir) + local global_ts = base_path .. "/typescript/lib" + local found_ts = "" + + local function check_dir(path) + found_ts = table.concat({ path, "typescript", "lib" }, "/") + if vim.loop.fs_stat(found_ts) then + return path + end + end + + -- Check frontend/node_modules first + if util.search_ancestors(root_dir .. '/frontend/node_modules', check_dir) then + return found_ts + end + + -- Check root node_modules + if util.search_ancestors(root_dir .. '/node_modules', check_dir) then + return found_ts + end + + return global_ts +end + +local function organize_imports() + local params = { + command = "_typescript.organizeImports", + arguments = { vim.api.nvim_buf_get_name(0) }, + title = "" + } + vim.lsp.buf.execute_command(params) +end + +return { + init_options = { + plugins = { + { + name = "@vue/typescript-plugin", + location = base_path .. "/@vue/typescript-plugin", + languages = { "javascript", "typescript", "vue", "react" }, + }, + }, + }, + filetypes = { + "javascript", + "typescript", + "vue", + "typescriptreact", + }, + commands = { + OrganizeImports = { + organize_imports, + description = "Organize Imports" + } + }, + on_new_config = function(new_config, new_root_dir) + if get_typescript_server_path then + new_config.init_options.typescript = new_config.init_options.typescript or {} + new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) + else + vim.notify("get_typescript_server_path is not defined", vim.log.levels.ERROR) + end + end, +} diff --git a/.config/nvim/lua/lsp/servers/yamlls.lua b/.config/nvim/lua/lsp/servers/yamlls.lua new file mode 100644 index 0000000..f0b05d7 --- /dev/null +++ b/.config/nvim/lua/lsp/servers/yamlls.lua @@ -0,0 +1,14 @@ +return { + settings = { + yaml = { + keyOrdering = false, + format = { + enable = true, + }, + validate = true, + schemaStore = { + enable = true, + }, + }, + }, +} diff --git a/.config/nvim/lua/lsp/utils.lua b/.config/nvim/lua/lsp/utils.lua new file mode 100644 index 0000000..3bdf8c3 --- /dev/null +++ b/.config/nvim/lua/lsp/utils.lua @@ -0,0 +1,78 @@ +local M = {} + +-- Find global node_modules path +function M.find_node_modules_path() + local paths = { + "/usr/lib/node_modules", + "/usr/local/lib/node_modules", + "/opt/homebrew/lib/node_modules" + } + + for _, path in ipairs(paths) do + if vim.loop.fs_stat(path) then + return path + end + end + + return nil +end + +-- Check if a file exists +function M.file_exists(path) + return vim.fn.filereadable(path) == 1 +end + +-- Check if a directory exists +function M.dir_exists(path) + return vim.fn.isdirectory(path) == 1 +end + +-- Get project root directory +function M.get_project_root() + return vim.loop.cwd() +end + +-- Setup common LSP keymaps (you can move the keymap logic here if desired) +function M.setup_lsp_keymaps(bufnr) + local keymap = vim.keymap + local function map(mode, lhs, rhs, desc) + keymap.set(mode, lhs, rhs, { + buffer = bufnr, + noremap = true, + silent = true, + desc = desc + }) + end + + -- Navigation + map("n", "gr", "Telescope lsp_references", "Show LSP references") + map("n", "gD", vim.lsp.buf.declaration, "Go to declaration") + map("n", "gd", "Telescope lsp_definitions", "Show LSP definitions") + map("n", "gi", "Telescope lsp_implementations", "Show LSP implementations") + map("n", "gt", "Telescope lsp_type_definitions", "Show LSP type definitions") + + -- Actions + map({ "n", "v" }, "ca", vim.lsp.buf.code_action, "See available code actions") + map("n", "rn", vim.lsp.buf.rename, "Smart rename") + + -- Diagnostics + map("n", "D", "Telescope diagnostics bufnr=0", "Show buffer diagnostics") + map("n", "d", vim.diagnostic.open_float, "Show line diagnostics") + map("n", "[d", function() + vim.diagnostic.jump({ count = -1, float = true }) + end, "Go to previous diagnostic") + map("n", "]d", function() + vim.diagnostic.jump({ count = 1, float = true }) + end, "Go to next diagnostic") + map("n", "[e", function() + vim.diagnostic.jump({ count = -1, float = true, severity = vim.diagnostic.severity.ERROR }) + end, "Go to previous diagnostic (error only)") + map("n", "]e", function() + vim.diagnostic.jump({ count = 1, float = true, severity = vim.diagnostic.severity.ERROR }) + end, "Go to next diagnostic (error only)") + + -- Documentation + map("n", "K", vim.lsp.buf.hover, "Show documentation for what is under cursor") +end + +return M diff --git a/.config/nvim/lua/plugins/alpha.lua b/.config/nvim/lua/plugins/alpha.lua deleted file mode 100644 index 31df700..0000000 --- a/.config/nvim/lua/plugins/alpha.lua +++ /dev/null @@ -1,44 +0,0 @@ -return { - 'goolord/alpha-nvim', - dependencies = { - 'echasnovski/mini.icons', - 'MaximilianLloyd/ascii.nvim', - }, - enabled = false, - config = function () - local alpha = require("alpha") - local dashboard = require("alpha.themes.dashboard") - - local neovim_lean = { - [[ ]], - [[ _/ _/ _/ _/ _/ ]], - [[ _/_/ _/ _/_/ _/_/ _/ _/ _/_/_/ _/_/ ]], - [[ _/ _/ _/ _/_/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ ]], - [[ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ ]], - [[ _/ _/ _/_/_/ _/_/ _/ _/ _/ _/ _/ ]], - [[ ]], - } - - -- Set the ASCII art - dashboard.section.header.val = require('ascii').get_random('text', 'slogons') - - -- Remove other sections (buttons, footer, etc.) to show only the ASCII art - dashboard.section.buttons.val = {} - dashboard.section.footer.val = {} - - local function get_center_padding() - local total_lines = vim.fn.winheight(0) - local art_lines = #dashboard.section.header.val - return math.floor((total_lines - art_lines) / 2) - end - - -- Center the header - dashboard.opts.layout = { - { type = "padding", val = get_center_padding() }, -- Add some vertical padding - dashboard.section.header, - } - - -- Set up alpha with the modified dashboard - alpha.setup(dashboard.opts) - end -} diff --git a/.config/nvim/lua/plugins/avante.lua b/.config/nvim/lua/plugins/avante.lua deleted file mode 100644 index d5f08e4..0000000 --- a/.config/nvim/lua/plugins/avante.lua +++ /dev/null @@ -1,55 +0,0 @@ -return { - "yetone/avante.nvim", - event = "VeryLazy", - version = false, - keys = { - "A", - "AvanteToggle" - }, - opts = { - behaviour = { - auto_suggestions = false, -- Experimental stage - auto_set_highlight_group = true, - auto_set_keymaps = false, - auto_apply_diff_after_generation = false, - support_paste_from_clipboard = false, - minimize_diff = true, -- Whether to remove unchanged lines when applying a code block - enable_token_counting = true, -- Whether to enable token counting. Default to true. - }, - }, - build = "make", - dependencies = { - "nvim-treesitter/nvim-treesitter", - "stevearc/dressing.nvim", - "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim", - "echasnovski/mini.pick", - "nvim-telescope/telescope.nvim", - "nvim-tree/nvim-web-devicons", - { - -- support for image pasting - "HakonHarnes/img-clip.nvim", - event = "VeryLazy", - opts = { - -- recommended settings - default = { - embed_image_as_base64 = false, - prompt_for_file_name = false, - drag_and_drop = { - insert_mode = true, - }, - -- required for Windows users - use_absolute_path = true, - }, - }, - }, - { - -- Make sure to set this up properly if you have lazy=true - 'MeanderingProgrammer/render-markdown.nvim', - opts = { - file_types = { "markdown", "Avante" }, - }, - ft = { "markdown", "Avante" }, - }, - }, -} diff --git a/.config/nvim/lua/plugins/blink.lua b/.config/nvim/lua/plugins/blink.lua index 563b823..8acc002 100644 --- a/.config/nvim/lua/plugins/blink.lua +++ b/.config/nvim/lua/plugins/blink.lua @@ -2,10 +2,9 @@ return { 'saghen/blink.cmp', lazy = false, dependencies = { - 'rafamadriz/friendly-snippets', - 'mikavilpas/blink-ripgrep.nvim', + { 'rafamadriz/friendly-snippets' }, { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true }, - { 'saghen/blink.compat', version = '2.*', lazy = true, opts = {} }, + { 'saghen/blink.compat', version = '2.*', lazy = true, opts = {} }, }, version = '1.*', @@ -13,18 +12,38 @@ return { completion = { menu = { auto_show = true, - winblend = vim.o.pumblend, - + scrollbar = true, + border = 'single', draw = { columns = { - { "label", "label_description", gap = 1 }, - { "kind_icon", "kind", gap = 1 } + { "label", "label_description", gap = 1 }, + { "kind_icon", "kind", gap = 1 } }, + components = { + kind_icon = { + ellipsis = false, + text = function(ctx) + return ctx.kind_icon .. ctx.icon_gap + end, + highlight = function(ctx) + return 'BlinkCmpKind' .. ctx.kind + end, + } + } } }, - documentation = { auto_show = true, auto_show_delay_ms = 500 }, + documentation = { + auto_show = true, + auto_show_delay_ms = 200, -- Faster doc display + window = { + border = 'single', + winblend = vim.o.pumblend, + max_width = 80, + max_height = 20, + } + }, ghost_text = { enabled = false }, }, @@ -56,9 +75,22 @@ return { signature = { enabled = true, window = { + border = 'single', winblend = vim.o.pumblend, }, }, }, - opts_extend = { "sources.default" } + opts_extend = { "sources.default" }, + config = function(_, opts) + require('blink.cmp').setup(opts) + + -- Optional: Set up highlights + vim.api.nvim_set_hl(0, 'BlinkCmpMenu', { link = 'Pmenu' }) + vim.api.nvim_set_hl(0, 'BlinkCmpMenuBorder', { link = 'Pmenu' }) + vim.api.nvim_set_hl(0, 'BlinkCmpMenuSelection', { link = 'PmenuSel' }) + vim.api.nvim_set_hl(0, 'BlinkCmpDoc', { link = 'NormalFloat' }) + vim.api.nvim_set_hl(0, 'BlinkCmpDocBorder', { link = 'FloatBorder' }) + vim.api.nvim_set_hl(0, 'BlinkCmpSignatureHelp', { link = 'NormalFloat' }) + vim.api.nvim_set_hl(0, 'BlinkCmpSignatureHelpBorder', { link = 'FloatBorder' }) + end } diff --git a/.config/nvim/lua/plugins/claude-code.lua b/.config/nvim/lua/plugins/claude-code.lua new file mode 100644 index 0000000..f335248 --- /dev/null +++ b/.config/nvim/lua/plugins/claude-code.lua @@ -0,0 +1,11 @@ +return { + "greggh/claude-code.nvim", + dependencies = { + "nvim-lua/plenary.nvim", -- Required for git operations + }, + config = function() + require("claude-code").setup() + + vim.keymap.set('n', 'CC', 'ClaudeCode', { desc = 'Toggle Claude Code' }) + end +} diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua index 3c8b152..6d40c7d 100644 --- a/.config/nvim/lua/plugins/colorscheme.lua +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -38,6 +38,7 @@ return { "scottmckendry/cyberdream.nvim", lazy = false, priority = 1000, + enabled = false, config = function() require("cyberdream").setup({ variant = "default", @@ -79,4 +80,12 @@ return { vim.cmd("colorscheme cyberdream") end }, + { + "EdenEast/nightfox.nvim", + lazy = false, + priority = 1000, + config = function() + vim.cmd("colorscheme carbonfox") + end + } } diff --git a/.config/nvim/lua/plugins/fugitive.lua b/.config/nvim/lua/plugins/fugitive.lua index 182e9c3..0593c3b 100644 --- a/.config/nvim/lua/plugins/fugitive.lua +++ b/.config/nvim/lua/plugins/fugitive.lua @@ -6,46 +6,167 @@ return { "shumphrey/fugitive-gitlab.vim", }, config = function() - vim.opt.diffopt = vim.opt.diffopt + "vertical" - vim.opt.display = vim.opt.display + "lastline" + -- Git diff settings + vim.opt.diffopt:append("vertical") + vim.opt.display:append("lastline") - local fugitive_augroup = vim.api.nvim_create_augroup("fugitive_mappings", { clear = true }) + -- Helper function for consistent keymap creation + local function map(mode, lhs, rhs, desc, opts) + opts = opts or {} + opts.desc = desc + opts.noremap = true + opts.silent = true + vim.keymap.set(mode, lhs, rhs, opts) + end + + -- Buffer-local mappings for fugitive buffers + local function set_fugitive_buffer_mappings() + local buf_opts = { buffer = 0, noremap = true, silent = true } - local function set_fugitive_mappings() - local opts = { noremap = true, silent = true } + -- Git operations + map("n", "gp", "Git push", "Git push", buf_opts) + map("n", "gP", "Git pull", "Git pull", buf_opts) + map("n", "gc", "Git commit", "Git commit", buf_opts) - vim.api.nvim_buf_set_keymap(0, "n", "gp", "Git push", opts) - vim.api.nvim_buf_set_keymap(0, "n", "gP", "Git pull", opts) - vim.api.nvim_buf_set_keymap(0, "n", "gc", "Git commit", opts) + -- Additional useful fugitive buffer mappings + map("n", "q", "close", "Close fugitive buffer", buf_opts) + map("n", "gd", "Gvdiffsplit", "Git diff split", buf_opts) + map("n", "gb", "Git blame", "Git blame", buf_opts) end - -- Create an autocmd to trigger the function when entering a Fugitive buffer + -- Auto-command for fugitive buffer mappings + local fugitive_augroup = vim.api.nvim_create_augroup("fugitive_mappings", { clear = true }) vim.api.nvim_create_autocmd("FileType", { group = fugitive_augroup, pattern = "fugitive", - callback = set_fugitive_mappings, + callback = set_fugitive_buffer_mappings, + desc = "Set fugitive buffer-local mappings", }) - local opts = { noremap = true, silent = true } + -- Enhanced line-based git log function + local function git_log_range() + local mode = vim.fn.mode() + local start_line, end_line + + if mode == 'V' or mode == 'v' then + -- Visual mode - get selected range + local start_pos = vim.fn.getpos("'<") + local end_pos = vim.fn.getpos("'>") + start_line = start_pos[2] + end_line = end_pos[2] + else + -- Normal mode - use current line + start_line = vim.fn.line(".") + end_line = start_line + end + + -- Validate line numbers + if start_line <= 0 or end_line <= 0 then + vim.notify("Invalid line range selected", vim.log.levels.WARN) + return + end - vim.keymap.set("n", "gg", function () + local filepath = vim.fn.expand("%:.") + if filepath == "" then + vim.notify("No file in current buffer", vim.log.levels.WARN) + return + end + + -- Ensure proper order + if start_line > end_line then + start_line, end_line = end_line, start_line + end + + local cmd = string.format("Git log -L %d,%d:%s", start_line, end_line, filepath) + vim.cmd(cmd) + end + + -- Global git mappings + map("n", "gg", function() vim.cmd("Git") - end, opts) + end, "Open git status") - vim.keymap.set("v", "gl", function() - local startPos = vim.fn.getpos("v") - local endPos = vim.fn.getpos(".") + map("n", "gl", function() + vim.cmd("Git log --oneline -20") + end, "Git log (last 20)") - local startLine = math.min(startPos[2], endPos[2]) - local endLine = math.max(startPos[2], endPos[2]) + map("n", "gL", function() + vim.cmd("Git log") + end, "Git log (detailed)") - if startLine == 0 or endLine == 0 then - vim.notify(vim.inspect(vim.fn.getpos("'<")) .. " to " .. vim.inspect(vim.fn.getpos("'>"))) - return + map({ "n", "v" }, "gr", git_log_range, "Git log for range/line") + + map("n", "gs", function() + vim.cmd("Git status") + end, "Git status") + + map("n", "gd", function() + vim.cmd("Gvdiffsplit") + end, "Git diff split") + + map("n", "gb", function() + vim.cmd("Git blame") + end, "Git blame") + + map("n", "ga", function() + vim.cmd("Git add %") + end, "Git add current file") + + map("n", "gA", function() + vim.cmd("Git add .") + end, "Git add all") + + -- Git stash operations + map("n", "gss", function() + vim.cmd("Git stash") + end, "Git stash") + + map("n", "gsp", function() + vim.cmd("Git stash pop") + end, "Git stash pop") + + map("n", "gsl", function() + vim.cmd("Git stash list") + end, "Git stash list") + + -- Branch operations + map("n", "gco", function() + local branch = vim.fn.input("Branch name: ") + if branch ~= "" then + vim.cmd("Git checkout " .. branch) end + end, "Git checkout branch") - vim.cmd(string.format("Git log -L %d,%d:%s", startLine, endLine, vim.fn.expand("%:."))) - end, opts) + map("n", "gcb", function() + local branch = vim.fn.input("New branch name: ") + if branch ~= "" then + vim.cmd("Git checkout -b " .. branch) + end + end, "Git create and checkout branch") + + -- Additional autocmds for better fugitive experience + vim.api.nvim_create_autocmd("FileType", { + group = fugitive_augroup, + pattern = "gitcommit", + callback = function() + -- Enable spell checking for commit messages + vim.opt_local.spell = true + vim.opt_local.spelllang = "en_us" + -- Position cursor at the beginning + vim.cmd("startinsert") + end, + desc = "Git commit buffer settings", + }) + + -- Auto-close fugitive buffers when done + vim.api.nvim_create_autocmd("BufReadPost", { + group = fugitive_augroup, + pattern = "fugitive:*", + callback = function() + vim.opt_local.bufhidden = "delete" + end, + desc = "Auto-delete fugitive buffers", + }) end, }, { diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 560db61..1470502 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -5,70 +5,21 @@ return { { "saghen/blink.cmp" }, { "antosha417/nvim-lsp-file-operations", config = true }, { "williamboman/mason.nvim", config = true }, - { "williamboman/mason-lspconfig.nvim" }, - { "WhoIsSethDaniel/mason-tool-installer.nvim" }, - { "j-hui/fidget.nvim", opts = {} }, - { "folke/neodev.nvim", opts = {} }, + { "williamboman/mason-lspconfig.nvim" }, + { "WhoIsSethDaniel/mason-tool-installer.nvim" }, + { "j-hui/fidget.nvim", opts = {} }, + { "folke/neodev.nvim", opts = {} }, + { 'dmmulroy/ts-error-translator.nvim', opts = {} }, }, config = function() local lspconfig = require("lspconfig") - local util = require("lspconfig.util") - - local keymap = vim.keymap + local utils = require("lsp.utils") vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }), callback = function(event) - local opts = { noremap = true, silent = true } - opts.desc = "Show LSP references" - keymap.set("n", "gr", "Telescope lsp_references", opts) - - opts.desc = "Go to declaration" - keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - - opts.desc = "Show LSP definitions" - keymap.set("n", "gd", "Telescope lsp_definitions", opts) - - opts.desc = "Show LSP implementations" - keymap.set("n", "gi", "Telescope lsp_implementations", opts) - - opts.desc = "Show LSP type definitions" - keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) - - opts.desc = "See available code actions" - keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) - - opts.desc = "Smart rename" - keymap.set("n", "rn", vim.lsp.buf.rename, opts) - - opts.desc = "Show buffer diagnostics" - keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) - - opts.desc = "Show line diagnostics" - keymap.set("n", "d", vim.diagnostic.open_float, opts) - - opts.desc = "Go to previous diagnostic" - keymap.set("n", "[d", function() - vim.diagnostic.jump({ count = -1, float = true }) - end, opts) - - opts.desc = "Go to next diagnostic" - keymap.set("n", "]d", function() - vim.diagnostic.jump({ count = 1, float = true }) - end, opts) - - opts.desc = "Go to previous diagnostic (error only)" - keymap.set("n", "[e", function() - vim.diagnostic.jump({ count = -1, float = true, severity = vim.diagnostic.severity.ERROR }) - end, opts) - - opts.desc = "Go to next diagnostic (error only)" - keymap.set("n", "]e", function() - vim.diagnostic.jump({ count = 1, float = true, severity = vim.diagnostic.severity.ERROR }) - end, opts) - - opts.desc = "Show documentation for what is under cursor" - keymap.set("n", "K", vim.lsp.buf.hover, opts) + -- Use the utility function to setup keymaps + utils.setup_lsp_keymaps(event.buf) local client = vim.lsp.get_client_by_id(event.data.client_id) if client and client.server_capabilities.documentHighlightProvider then @@ -82,6 +33,20 @@ return { end, }) + vim.diagnostic.config({ + virtual_text = { + prefix = "●", + source = "if_many", + }, + float = { + border = "rounded", + }, + signs = true, + underline = true, + update_in_insert = false, + severity_sort = true, + }) + local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = vim.tbl_deep_extend( "force", @@ -89,186 +54,22 @@ return { require('blink.cmp').get_lsp_capabilities() ) - local base_path = "" - if (vim.loop.fs_stat("/usr/lib/node_modules")) then - base_path = "/usr/lib/node_modules" - elseif (vim.loop.fs_stat("/usr/local/lib/node_modules")) then - base_path = "/usr/local/lib/node_modules" - elseif (vim.loop.fs_stat("/opt/homebrew/lib/node_modules")) then - base_path = "/opt/homebrew/lib/node_modules" - end - - local function get_typescript_server_path(root_dir) - local global_ts = base_path .. "/typescript/lib" - local found_ts = "" - local function check_dir(path) - found_ts = table.concat({ path, "typescript", "lib" }, "/") - if vim.loop.fs_stat(found_ts) then - return path - end - end - - if util.search_ancestors(root_dir .. '/frontend/node_modules', check_dir) then - return found_ts - end - - if util.search_ancestors(root_dir .. '/node_modules', check_dir) then - return found_ts + -- Load server configurations from separate files + local servers_path = vim.fn.stdpath("config") .. "/lua/lsp/servers" + local server_files = vim.fn.glob(servers_path .. "/*.lua", false, true) + + local servers = {} + for _, file in ipairs(server_files) do + local server_name = vim.fn.fnamemodify(file, ":t:r") + local ok, server_config = pcall(require, "lsp.servers." .. server_name) + if ok then + servers[server_name] = server_config + else + vim.notify("Failed to load server config: " .. server_name, vim.log.levels.WARN) end - - return global_ts - end - - local function organize_imports() - local params = { - command = "_typescript.organizeImports", - arguments = { vim.api.nvim_buf_get_name(0) }, - title = "" - } - vim.lsp.buf.execute_command(params) end - local servers = { - ts_ls = { - init_options = { - plugins = { - { - name = "@vue/typescript-plugin", - location = base_path .. "/@vue/typescript-plugin", - languages = { "javascript", "typescript", "vue", "react" }, - }, - }, - }, - filetypes = { - "javascript", - "typescript", - "vue", - "typescriptreact", - }, - commands = { - OrganizeImports = { - organize_imports, - description = "Organize Imports" - } - }, - on_new_config = function(new_config, new_root_dir) - if get_typescript_server_path then - new_config.init_options.typescript = new_config.init_options.typescript or {} - new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) - else - vim.notify("get_typescript_server_path is not defined", vim.log.levels.ERROR) - end - end, - }, - - cssls = {}, - - intelephense = { - root_dir = function(pattern) - local root = util.root_pattern("composer.json", "composer.lock")(pattern) - return root or vim.fn.getcwd() - end, - single_file_support = false, - init_options = { - licenceKey = vim.fn.expand("$HOME/.local/share/nvim/intelephense-licence.txt"), - }, - settings = { - intelephense = { - format = { - enable = true, - sortUseStatements = true, - }, - }, - }, - }, - - gopls = { - cmd = { "gopls" }, - filetypes = { "go", "gomod", "gowork", "gotmpl" }, - root_dir = util.root_pattern("go.work", "go.mod", ".git"), - settings = { - gopls = { - completeUnimported = true, - usePlaceholders = true, - analyses = { - unusedparams = true, - }, - }, - }, - }, - - lua_ls = { - settings = { -- custom settings for lua - Lua = { - -- make the language server recognize "vim" global - diagnostics = { - globals = { "vim" }, - }, - workspace = { - -- make language server aware of runtime files - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, - }, - }, - }, - }, - }, - - -- dartls = { - -- cmd = { "/opt/flutter/bin/dart", "language-server", "--protocol=lsp" }, - -- }, - - rust_analyzer = { - diagnostics = { - enable = false, - }, - }, - - pyright = { - -- before_init = function(_, config) - -- config.settings.python.pythonpath = get_python_path(config.root_dir) - -- end - }, - - yamlls = { - settings = { - yaml = { - keyOrdering = false, - }, - }, - }, - - clangd = { - cmd = { - "clangd", - "--compile-commands-dir=.", - "--header-insertion=never", - "--cross-file-rename", - "--clang-tidy" - }, - filetypes = { "c", "cpp" }, - root_dir = require('lspconfig.util').root_pattern( - '.clangd', - '.clang-tidy', - '.clang-format', - 'compile_commands.json', - 'compile_flags.txt', - 'configure.in', - '.git', - 'Makefile' - ), - }, - - } - - require("mason").setup() - - require("mason-lspconfig").setup({ - ensure_installed = {}, - automatic_enable = false, - }) - + -- Setup all servers for server_name, server in pairs(servers) do server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) lspconfig[server_name].setup(server) diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index 56a67c7..1ee6237 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -8,43 +8,76 @@ return { local lualine = require("lualine") local lazy_status = require("lazy.status") - local function macro_recording() - local recording_register = vim.fn.reg_recording() - if recording_register == "" then - return "" - else - return "Recording @" .. recording_register - end - end + -- Custom components + local function macro_recording() + local recording_register = vim.fn.reg_recording() + if recording_register == "" then + return "" + else + return "Recording @" .. recording_register + end + end + + local function buffer_count() + local buffers = vim.fn.getbufinfo({ buflisted = 1 }) + return "Buffers: " .. #buffers + end + lualine.setup({ options = { theme = "auto", - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, globalstatus = true, + refresh = { + statusline = 1000, -- Refresh every second for macro recording + }, }, extensions = { "fugitive", "oil", "quickfix", + "trouble", -- Add if you use trouble.nvim + "mason", -- Add if you use mason.nvim }, sections = { + lualine_a = { + { "mode", fmt = function(str) return str:sub(1,1) end }, -- Shorter mode display + }, lualine_b = { - { "branch" }, - { "diff" }, - { "diagnostics" }, + { "branch", icon = "" }, { - function() - local buffers = vim.fn.getbufinfo({ buflisted = true }) - return "Buffers: " .. #buffers - end, + "diff", + colored = true, + symbols = { added = " ", modified = " ", removed = " " } + }, + { + "diagnostics", + sources = { "nvim_lsp" }, + symbols = { error = " ", warn = " ", info = " ", hint = " " } }, }, lualine_c = { - { "filename", file_status = true, path = 1 }, + { + "filename", + file_status = true, + path = 1, -- Show relative path + shorting_target = 40, -- Shorten long paths + symbols = { + modified = "", + readonly = "", + unnamed = "[No Name]", + newfile = "[New]", + } + }, { "harpoon2" }, - { macro_recording, color = { fg = "#ff9e64", gui = "bold" } }, + { + macro_recording, + color = { fg = "#ff9e64", gui = "bold" }, + separator = { left = "" } + }, + { buffer_count, color = { fg = "#7aa2f7" } }, }, lualine_x = { { @@ -52,14 +85,23 @@ return { cond = lazy_status.has_updates, color = { fg = "#ff9e64" }, }, - { "fileformat" }, - { "filetype" }, + -- Remove fileformat unless you really need it + -- { "fileformat" }, + { "filetype", colored = true }, }, lualine_y = { { "progress" }, }, lualine_z = { - { "location" } + { "location" }, + }, + }, + inactive_sections = { + lualine_c = { + { "filename", file_status = true, path = 1 } + }, + lualine_x = { + { "filetype" } }, }, }) diff --git a/.config/nvim/lua/plugins/neotest.lua b/.config/nvim/lua/plugins/neotest.lua index c605cd1..6f80987 100644 --- a/.config/nvim/lua/plugins/neotest.lua +++ b/.config/nvim/lua/plugins/neotest.lua @@ -1,5 +1,6 @@ return { "nvim-neotest/neotest", + commit = '52fca6717ef972113ddd6ca223e30ad0abb2800c', event = "VeryLazy", dependencies = { "nvim-lua/plenary.nvim", @@ -9,7 +10,6 @@ return { -- Adapters "tovijaeschke/neotest-phpunit", "nvim-neotest/neotest-go", - 'nvim-neotest/neotest-jest', }, config = function() local neotest = require("neotest") @@ -63,13 +63,13 @@ return { }, args = { "-count=1", "-timeout=60s" }, }), - require('neotest-jest')({ - jestCommand = "npm test --", - env = { CI = true }, - cwd = function(path) - return vim.fn.getcwd() - end, - }), + -- require('neotest-jest')({ + -- jestCommand = "npm test --", + -- env = { CI = true }, + -- cwd = function(path) + -- return vim.fn.getcwd() + -- end, + -- }), }, }) end, diff --git a/.config/nvim/lua/plugins/nvim-go.lua b/.config/nvim/lua/plugins/nvim-go.lua index 7d8ec4f..efc86ee 100644 --- a/.config/nvim/lua/plugins/nvim-go.lua +++ b/.config/nvim/lua/plugins/nvim-go.lua @@ -5,7 +5,7 @@ return { "neovim/nvim-lspconfig", "nvim-treesitter/nvim-treesitter", }, - event = { "CmdlineEnter" }, + event = "VeryLazy", ft = { "go", 'gomod' }, build = ':lua require("go.install").update_all_sync()', config = function() diff --git a/.config/nvim/lua/plugins/refactor.lua b/.config/nvim/lua/plugins/refactor.lua deleted file mode 100644 index 3f09d47..0000000 --- a/.config/nvim/lua/plugins/refactor.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - "ThePrimeagen/refactoring.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-treesitter/nvim-treesitter", - }, - lazy = false, - opts = {}, -} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 4314af3..93326ad 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -10,31 +10,31 @@ return { config = function() local telescope = require("telescope") local actions = require("telescope.actions") - local action_state = require('telescope.actions.state') + local builtin = require("telescope.builtin") local previewers = require("telescope.previewers") local previewers_utils = require("telescope.previewers.utils") - local sorters = require("telescope.sorters") - local builtin = require("telescope.builtin") + -- Configuration constants + local MAX_FILE_SIZE = 100000 + + -- Enable line numbers in telescope previews vim.api.nvim_create_autocmd('User', { pattern = 'TelescopePreviewerLoaded', - callback = function(args) + callback = function() vim.wo.number = true end, }) - local max_size = 100000 - local truncate_large_files = function(filepath, bufnr, opts) + -- Truncate large files in preview to improve performance + local function truncate_large_files(filepath, bufnr, opts) opts = opts or {} - filepath = vim.fn.expand(filepath) - ---@diagnostic disable-next-line: undefined-field - vim.loop.fs_stat(filepath, function(_, stat) - if not stat then - return - end - if stat.size > max_size then - local cmd = { "head", "-c", max_size, filepath } + + vim.uv.fs_stat(filepath, function(_, stat) + if not stat then return end + + if stat.size > MAX_FILE_SIZE then + local cmd = { "head", "-c", tostring(MAX_FILE_SIZE), filepath } previewers_utils.job_maker(cmd, bufnr, opts) else previewers.buffer_previewer_maker(filepath, bufnr, opts) @@ -42,9 +42,32 @@ return { end) end + -- Cache git status to avoid repeated system calls + local is_inside_work_tree = {} + + local function smart_project_files() + local cwd = vim.fn.getcwd() + + if is_inside_work_tree[cwd] == nil then + vim.fn.system("git rev-parse --is-inside-work-tree") + is_inside_work_tree[cwd] = vim.v.shell_error == 0 + end + + local opts = is_inside_work_tree[cwd] + and { show_untracked = true, hidden = true } + or {} + + local picker = is_inside_work_tree[cwd] + and builtin.git_files + or builtin.find_files + + picker(opts) + end + + -- Telescope setup telescope.setup({ defaults = { - file_sorter = sorters.get_fzy_sorter, + file_sorter = require("telescope.sorters").get_fzy_sorter, color_devicons = true, buffer_previewer_maker = truncate_large_files, @@ -55,13 +78,20 @@ return { layout_config = { prompt_position = "top", + horizontal = { + preview_width = 0.6, + }, + vertical = { + mirror = false, + }, }, - border = {}, - -- borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - borderchars = { " ", " ", " ", " ", " ", " ", " ", " " }, + -- Modern borderchars + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + + -- Performance optimizations use_less = true, - set_env = { ['COLORTERM'] = 'truecolor' }, + set_env = { COLORTERM = "truecolor" }, mappings = { i = { @@ -70,9 +100,15 @@ return { [""] = actions.cycle_history_next, [""] = actions.cycle_history_prev, [""] = actions.smart_send_to_qflist + actions.open_qflist, + [""] = false, -- Clear prompt + [""] = actions.close, -- Close prompt + }, + n = { + ["q"] = actions.close, }, }, }, + pickers = { diagnostics = { initial_mode = "normal", @@ -80,10 +116,31 @@ return { preview_cutoff = 9999, }, }, + buffers = { + sort_mru = true, + sort_lastused = true, + mappings = { + i = { + [""] = actions.delete_buffer, + }, + n = { + ["dd"] = actions.delete_buffer, + }, + }, + }, + find_files = { + hidden = true, + find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" }, + }, }, + extensions = { undo = { side_by_side = true, + layout_strategy = "vertical", + layout_config = { + preview_height = 0.8, + }, mappings = { i = { [""] = require("telescope-undo.actions").restore, @@ -96,91 +153,76 @@ return { }, }, }, + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, }, }) + -- Load extensions telescope.load_extension("fzf") telescope.load_extension("undo") telescope.load_extension("ui-select") - -- We cache the results of "git rev-parse" - -- Process creation is expensive in Windows, so this reduces latency - local is_inside_work_tree = {} - - local project_files = function() - local cwd = vim.fn.getcwd() - if is_inside_work_tree[cwd] == nil then - vim.fn.system("git rev-parse --is-inside-work-tree") - is_inside_work_tree[cwd] = vim.v.shell_error == 0 - end - - if is_inside_work_tree[cwd] then - builtin.git_files({ show_untracked = true, hidden = true }) - else - builtin.find_files({}) - end + -- Keymaps + local function map(mode, lhs, rhs, desc) + vim.keymap.set(mode, lhs, rhs, { desc = desc, noremap = true, silent = true }) end - -- set keymaps - local keymap = vim.keymap - - keymap.set("n", "ff", function() + -- File navigation + map("n", "ff", function() require("plugins.telescope.multigrep").live_multgrep() - end, {}) - - keymap.set("n", "p", project_files, {}) - - keymap.set("n", "fr", builtin.resume, {}) + end, "Live multigrep") - keymap.set("n", "ss", builtin.spell_suggest, {}) + map("n", "p", smart_project_files, "Find project files") + map("n", "fr", builtin.resume, "Resume last telescope") + map("n", "fb", builtin.buffers, "Find buffers") + map("n", "fo", builtin.oldfiles, "Find recent files") - keymap.set("n", "ql", builtin.quickfix, {}) - keymap.set("n", "qhl", builtin.quickfixhistory, {}) + -- Search + map("n", "gf", function() + builtin.grep_string({ search = vim.fn.expand("") }) + end, "Grep word under cursor") - keymap.set("n", "fb", builtin.buffers, {}) - keymap.set("n", "fo", builtin.oldfiles, {}) + map("n", "gF", function() + builtin.grep_string({ search = vim.fn.expand("") }) + end, "Grep WORD under cursor") - keymap.set("n", "m", builtin.marks, {}) + map("n", "gD", function() + builtin.find_files({ search_file = vim.fn.expand("") }) + end, "Find file with name under cursor") - keymap.set("n", "cc", builtin.commands, {}) - keymap.set("n", "ch", builtin.command_history, {}) - - keymap.set("n", "gb", function() + -- Git + map("n", "gb", function() builtin.git_branches({ - attach_mappings = function(_, map) - map("i", "", actions.git_delete_branch) - map("n", "", actions.git_delete_branch) + attach_mappings = function(_, map_func) + map_func("i", "", actions.git_delete_branch) + map_func("n", "", actions.git_delete_branch) return true end, }) - end, {}) - - keymap.set("n", "gc", builtin.git_commits, {}) - - keymap.set("n", "vh", builtin.help_tags, {}) - - keymap.set("n", "ds", builtin.lsp_document_symbols, {}) - keymap.set("n", "ws", builtin.lsp_workspace_symbols, {}) - keymap.set("n", "dws", builtin.lsp_dynamic_workspace_symbols, {}) - - keymap.set("n", "gf", function() - builtin.grep_string({ - search = vim.fn.expand(""), - }) - end) - - keymap.set("n", "gF", function() - builtin.grep_string({ - search = vim.fn.expand(""), - }) - end) - - keymap.set("n", "gD", function() - builtin.find_files({ - search_file = vim.fn.expand(""), - }) - end) - - vim.keymap.set("n", "u", "Telescope undo") + end, "Git branches") + + map("n", "gc", builtin.git_commits, "Git commits") + + -- LSP + map("n", "ds", builtin.lsp_document_symbols, "Document symbols") + map("n", "ws", builtin.lsp_workspace_symbols, "Workspace symbols") + map("n", "dws", builtin.lsp_dynamic_workspace_symbols, "Dynamic workspace symbols") + + -- Utilities + map("n", "u", "Telescope undo", "Undo history") + map("n", "ss", builtin.spell_suggest, "Spell suggestions") + map("n", "m", builtin.marks, "Marks") + map("n", "cc", builtin.commands, "Commands") + map("n", "ch", builtin.command_history, "Command history") + map("n", "vh", builtin.help_tags, "Help tags") + + -- Quickfix + map("n", "ql", builtin.quickfix, "Quickfix list") + map("n", "qhl", builtin.quickfixhistory, "Quickfix history") end, } diff --git a/.config/nvim/lua/plugins/telescope/multigrep.lua b/.config/nvim/lua/plugins/telescope/multigrep.lua index 3ad77f6..ef469ea 100644 --- a/.config/nvim/lua/plugins/telescope/multigrep.lua +++ b/.config/nvim/lua/plugins/telescope/multigrep.lua @@ -29,7 +29,7 @@ M.live_multgrep = function (opts) end ---@diagnostic disable-next-line: deprecated - return vim.tbl_flatten({ + return vim.iter({ args, { "--color=never", @@ -40,7 +40,7 @@ M.live_multgrep = function (opts) "--smart-case", "--hidden", } - }) + }):flatten():totable() end, entry_maker = make_entry.gen_from_vimgrep(opts), cwd = opts.cwd diff --git a/.config/nvim/lua/plugins/typr.lua b/.config/nvim/lua/plugins/typr.lua deleted file mode 100644 index 0b07cd7..0000000 --- a/.config/nvim/lua/plugins/typr.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - "nvzone/typr", - dependencies = "nvzone/volt", - opts = {}, - cmd = { "Typr", "TyprStats" }, -} diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile deleted file mode 100644 index 7591b60..0000000 --- a/.config/zsh/.zprofile +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/zsh -if [[ -z "$WAYLAND_DISPLAY" ]] && [[ -z "$DISPLAY" ]] && [[ "$XDG_VTNR" = 1 ]] && [[ $(tty) = /dev/tty1 ]]; then - if uwsm check may-start; then - exec uwsm start hyprland.desktop - fi -fi diff --git a/.profile b/.profile index adac541..8b6664d 100644 --- a/.profile +++ b/.profile @@ -1,5 +1,6 @@ #!/bin/sh if uwsm check may-start && uwsm select; then + echo "starting..." exec systemd-cat -t uwsm_start uwsm start default fi diff --git a/.tmux.conf b/.tmux.conf index 708c5ac..b35e4cc 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1,5 +1,5 @@ # set -g default-terminal "screen-256color" -set-option -sa terminal-overrides ",xterm*:Tc" +set-option -a terminal-features 'alacritty:RGB' # easy reload config bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded." @@ -75,23 +75,30 @@ bind-key -r f run-shell "tmux neww ~/.local/bin/tmux-sessionizer" bind-key -r m run-shell "~/.local/bin/tmux-music" +set -g mode-style "fg=#0c0c0c,bg=#b6b8bb" +set -g message-style "fg=#0c0c0c,bg=#b6b8bb" +set -g message-command-style "fg=#0c0c0c,bg=#b6b8bb" +set -g pane-border-style "fg=#b6b8bb" +set -g pane-active-border-style "fg=#78a9ff" +set -g status "on" +set -g status-justify "left" +set -g status-style "fg=#b6b8bb,bg=#0c0c0c" +set -g status-left-length "100" +set -g status-right-length "100" +set -g status-left-style NONE +set -g status-right-style NONE +set -g status-left "#[fg=#0c0c0c,bg=#78a9ff,bold] #S #[fg=#78a9ff,bg=#0c0c0c,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=#0c0c0c,bg=#0c0c0c,nobold,nounderscore,noitalics]#[fg=#78a9ff,bg=#0c0c0c] #{prefix_highlight} #[fg=#b6b8bb,bg=#0c0c0c,nobold,nounderscore,noitalics]#[fg=#0c0c0c,bg=#b6b8bb] %Y-%m-%d  %I:%M %p #[fg=#78a9ff,bg=#b6b8bb,nobold,nounderscore,noitalics]#[fg=#0c0c0c,bg=#78a9ff,bold] #h " +setw -g window-status-activity-style "underscore,fg=#7b7c7e,bg=#0c0c0c" +setw -g window-status-separator "" +setw -g window-status-style "NONE,fg=#7b7c7e,bg=#0c0c0c" +setw -g window-status-format "#[fg=#0c0c0c,bg=#0c0c0c,nobold,nounderscore,noitalics]#[default] #I  #W #F #[fg=#0c0c0c,bg=#0c0c0c,nobold,nounderscore,noitalics]" +setw -g window-status-current-format "#[fg=#0c0c0c,bg=#b6b8bb,nobold,nounderscore,noitalics]#[fg=#0c0c0c,bg=#b6b8bb,bold] #I  #W #F #[fg=#b6b8bb,bg=#0c0c0c,nobold,nounderscore,noitalics]" + # List of plugins set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' -# set -g @plugin "janoamaral/tokyo-night-tmux" -# set -g @tokyo-night-tmux_window_id_style digital - -# set -g @plugin 'Nybkox/tmux-kanagawa' -# set -g @kanagawa-show-powerline true -# set -g @kanagawa-theme 'wave' -# set -g @kanagawa-ignore-window-colors true - -set -g @plugin 'catppuccin/tmux#v2.1.3' - -set -g @catppuccin_flavour "cyberdream" -run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux - if "test ! -d ~/.tmux/plugins/tpm" \ "run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"