From b5629cf22f0ee7c69397c978bdd30d33166050f7 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 19 Dec 2024 15:51:27 +0200 Subject: [PATCH] refactor config --- .stylua.toml | 6 + after/ftplugin/rust.vim | 5 - after/plugin/lspsignature-theme.lua | 8 - after/plugin/telescope-theme.lua | 38 +- init.lua | 1873 +++++++++-------- lazy-lock.json | 79 +- lua/kickstart/health.lua | 52 + lua/kickstart/plugins/autopairs.lua | 16 + lua/kickstart/plugins/debug.lua | 148 ++ lua/kickstart/plugins/gitsigns.lua | 59 + lua/kickstart/plugins/indent_line.lua | 9 + lua/kickstart/plugins/lint.lua | 60 + lua/kickstart/plugins/neo-tree.lua | 25 + lua/old_dap_cfg.lua | 36 - .../init.lua} | 26 +- lua/personal/cmacro-align.lua | 111 - lua/personal/disable-builtin.lua | 17 - lua/personal/plugin-dev.lua | 11 - lua/personal/{uci.lua => uci/init.lua} | 13 +- lua/plugins/lualine.lua | 168 -- lua/plugins/luasnip.lua | 89 - lua/plugins/telescope.lua | 154 -- plugins/lldb-vscode.json | 17 - 23 files changed, 1407 insertions(+), 1613 deletions(-) create mode 100644 .stylua.toml delete mode 100644 after/ftplugin/rust.vim delete mode 100644 after/plugin/lspsignature-theme.lua create mode 100644 lua/kickstart/health.lua create mode 100644 lua/kickstart/plugins/autopairs.lua create mode 100644 lua/kickstart/plugins/debug.lua create mode 100644 lua/kickstart/plugins/gitsigns.lua create mode 100644 lua/kickstart/plugins/indent_line.lua create mode 100644 lua/kickstart/plugins/lint.lua create mode 100644 lua/kickstart/plugins/neo-tree.lua delete mode 100644 lua/old_dap_cfg.lua rename lua/personal/{add-include-guard.lua => add-include-guard/init.lua} (52%) delete mode 100644 lua/personal/cmacro-align.lua delete mode 100644 lua/personal/disable-builtin.lua delete mode 100644 lua/personal/plugin-dev.lua rename lua/personal/{uci.lua => uci/init.lua} (81%) delete mode 100644 lua/plugins/lualine.lua delete mode 100644 lua/plugins/luasnip.lua delete mode 100644 lua/plugins/telescope.lua delete mode 100644 plugins/lldb-vscode.json diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..139e939 --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 160 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferSingle" +call_parentheses = "None" diff --git a/after/ftplugin/rust.vim b/after/ftplugin/rust.vim deleted file mode 100644 index 1b6c850..0000000 --- a/after/ftplugin/rust.vim +++ /dev/null @@ -1,5 +0,0 @@ -set noexpandtab -set smartindent -set shiftwidth=2 -set tabstop=2 -set softtabstop=2 diff --git a/after/plugin/lspsignature-theme.lua b/after/plugin/lspsignature-theme.lua deleted file mode 100644 index 584a268..0000000 --- a/after/plugin/lspsignature-theme.lua +++ /dev/null @@ -1,8 +0,0 @@ -if vim.g.colors_name == "srcery" then - local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground - local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground - - vim.api.nvim_set_hl(0, "FloatBorder", {bg=hard_black, fg=bright_white}) - vim.api.nvim_set_hl(0, "FloatNormal", {bg=hard_black, fg=bright_white}) - vim.api.nvim_set_hl(0, "Pmenu", {bg=hard_black, fg=bright_white}) -end diff --git a/after/plugin/telescope-theme.lua b/after/plugin/telescope-theme.lua index fa2fa53..a6ad1ae 100644 --- a/after/plugin/telescope-theme.lua +++ b/after/plugin/telescope-theme.lua @@ -1,22 +1,20 @@ -if vim.g.colors_name == "srcery" then - local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground - local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground - local red = vim.api.nvim_get_hl_by_name("SrceryRed", true).foreground - local yellow = vim.api.nvim_get_hl_by_name("SrceryYellow", true).foreground - local gray1 = vim.api.nvim_get_hl_by_name("SrceryXgray1", true).foreground +local bright_white = vim.api.nvim_get_hl(0, { name = 'SrceryBrightWhite' }).fg +local hard_black = vim.api.nvim_get_hl(0, { name = 'SrceryHardBlack' }).fg +local red = vim.api.nvim_get_hl(0, { name = 'SrceryRed' }).fg +local yellow = vim.api.nvim_get_hl(0, { name = 'SrceryYellow' }).fg +local gray1 = vim.api.nvim_get_hl(0, { name = 'SrceryXgray1' }).fg - local TelescopePrompt = { - TelescopeBorder = {bg = hard_black, fg = hard_black}, - TelescopePromptBorder = {bg = gray1, fg = gray1}, - TelescopePromptNormal = {bg = gray1}, - TelescopePromptTitle = {fg = hard_black, bg = red }, - TelescopePreviewTitle = {fg = hard_black, bg = yellow }, - TelescopeNormal = {bg = hard_black, fg = bright_white}, - TelescopeResultsNormal = {bg = hard_black, fg = bright_white}, - TelescopePreviewNormal = {bg = hard_black, fg = bright_white}, - TelescopeSelection = {bg = hard_black, fg = bright_white, underline = true}, - } - for hl, col in pairs(TelescopePrompt) do - vim.api.nvim_set_hl(0, hl, col) - end +local TelescopePrompt = { + TelescopeBorder = { bg = hard_black, fg = hard_black }, + TelescopePromptBorder = { bg = gray1, fg = gray1 }, + TelescopePromptNormal = { bg = gray1 }, + TelescopePromptTitle = { fg = hard_black, bg = red }, + TelescopePreviewTitle = { fg = hard_black, bg = yellow }, + TelescopeNormal = { bg = hard_black, fg = bright_white }, + TelescopeResultsNormal = { bg = hard_black, fg = bright_white }, + TelescopePreviewNormal = { bg = hard_black, fg = bright_white }, + TelescopeSelection = { bg = hard_black, fg = bright_white, underline = true }, +} +for hl, col in pairs(TelescopePrompt) do + vim.api.nvim_set_hl(0, hl, col) end diff --git a/init.lua b/init.lua index 988525e..91c2516 100644 --- a/init.lua +++ b/init.lua @@ -1,982 +1,1035 @@ -vim.g.mapleader = " " -vim.g.maplocalleader = " " +-- Set as the leader key +-- See `:help mapleader` +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' -vim.g.python3_host_prog = "python3.10" +-- Set to true if you have a Nerd Font installed and selected in the terminal +vim.g.have_nerd_font = true -- If possible use 24 Bit Colors -if vim.fn.has("termguicolors") == 1 then +if vim.fn.has 'termguicolors' == 1 then vim.o.termguicolors = true end --- Bootstrap lazy.nvim -do - local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" - if not vim.loop.fs_stat(lazypath) then - vim.fn.system { - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - } - end - vim.opt.rtp:prepend(lazypath) -end - -require("lazy").setup({ - { - "NTBBloodbath/zig-tools.nvim", - -- Load zig-tools.nvim only in Zig buffers - ft = "zig", - config = function() - -- Initialize with default config - require("zig-tools").setup() - end, - dependencies = { - { - "akinsho/toggleterm.nvim", - config = function() - require("toggleterm").setup() - end, - }, - { - "nvim-lua/plenary.nvim", - module_pattern = "plenary.*" - } - }, - }, - - { - "folke/zen-mode.nvim", - opts = { - plugins = { - gitsigns = { enabled = true } - } - } - }, - "jwalton512/vim-blade", - "psliwka/vim-smoothie", - "tpope/vim-unimpaired", - "tpope/vim-eunuch", - "tpope/vim-surround", - "tpope/vim-repeat", - {"christoomey/vim-tmux-navigator", lazy=false}, - "michaeljsmith/vim-indent-object", - "godlygeek/tabular", - "mcauley-penney/tidy.nvim", - "editorconfig/editorconfig-vim", - "kevinhwang91/nvim-bqf", - "wellle/targets.vim", - - { - "backdround/global-note.nvim", - config = function() - require("global-note").setup({}) - end, - keys = { - { "n", function() require("global-note").toggle_note() end, desc = "Toggle [N]otes" }, - } - }, - - { - "krady21/compiler-explorer.nvim", - cmd = {"CECompile", "CECompileLive", "CEFormat", "CEAddLibrary", "CELoadExample", "CEOpenWebsite", "CEDeleteCache", "CEShowTooltip", "CEGotoLabel"} - }, - - { - "kdheepak/lazygit.nvim", - keys = { - { "gg", "LazyGit", desc = "Open lazygit" } - } - }, - - { - "unblevable/quick-scope", - init = function () - -- Trigger a highlight in the appropriate direction when pressing these keys: - vim.g.qs_highlight_on_keys = {"f", "F", "t", "T"} - vim.g.qs_max_chars = 150 - end - }, - - { - "stevearc/dressing.nvim", - dependencies = {"nvim-telescope/telescope.nvim"}, - opts = { - select = { - get_config = function(opts) - opts = opts or {} - local cfg = { - telescope = { - layout_config = { - -- width = 120, - -- height = 60, - width = 0.87, - height = 0.80, - }, - }, - } - if opts.kind == "legendary.nvim" then - cfg.telescope.sorter = require("telescope.sorters").fuzzy_with_index_bias({}) - end - return cfg - end, - }, - } - }, - - { "tikhomirov/vim-glsl", ft="glsl" }, - - { - "folke/todo-comments.nvim", - dependencies = { "nvim-lua/plenary.nvim"}, - opts = { signs = false } - }, - - -- Git related plugins - { - "f-person/git-blame.nvim", - config = function () - vim.g["gitblame_enabled"] = 0 - vim.g["gitblame_date_format"] = "%r" - end, - keys = { - { "gh", "GitBlameCopySHA" , desc = "[G]it blame, copy commit [h]ash" }, - { "go", "GitBlameOpenCommit", desc = "[G]it blame, [o]pen commit" }, - { "gt", "GitBlameToggle" , desc = "[G]it blame, [t]oggle" }, - } - }, - - { - "trmckay/based.nvim", - keys = { - { mode = {"n", "v"}, "b", function(...) require("based").convert(...) end, desc = "Convert [b]ase of number" } - } - }, - - -- Detect tabstop and shiftwidth automatically - "tpope/vim-sleuth", - - -- NOTE: This is where your plugins related to LSP can be installed. - -- The configuration is done below. Search for lspconfig to find it below. - { - -- LSP Configuration & Plugins - "neovim/nvim-lspconfig", - dependencies = { - -- Automatically install LSPs to stdpath for neovim - { "williamboman/mason.nvim", config = true }, - "williamboman/mason-lspconfig.nvim", - - -- Useful status updates for LSP - -- NOTE: `opts = {}` is the same as calling `require("fidget").setup({})` - { "j-hui/fidget.nvim", tag = "legacy", opts = {} }, - - -- Additional lua configuration, makes nvim stuff amazing! - "folke/neodev.nvim", - }, - }, - - { - "ray-x/lsp_signature.nvim", - opts = { - hint_enable = false, - toggle_key = nil, - handler_opts = { - border = { " ", " ", " ", " ", " ", " ", " ", " " } - } - } - }, - - { - -- Autocompletion - "hrsh7th/nvim-cmp", - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - "L3MON4D3/LuaSnip", - "saadparwaiz1/cmp_luasnip", - - -- Adds LSP completion capabilities - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - "onsails/lspkind-nvim", - - -- Adds a number of user-friendly snippets - "rafamadriz/friendly-snippets", - }, - }, - - -- Useful plugin to show you pending keybinds. - -- { "folke/which-key.nvim", opts = {} }, - { - -- Adds git related signs to the gutter, as well as utilities for managing changes - "lewis6991/gitsigns.nvim", - opts = { - signs = { - add = { text = "+" }, - change = { text = "~" }, - delete = { text = "_" }, - topdelete = { text = "‾" }, - changedelete = { text = "~" }, - }, - on_attach = function() - local function keymap(mode, keybind, cmd, desc) - vim.keymap.set(mode, keybind, cmd, {desc=desc, buffer=true}) - end - keymap({"v","n"}, "hs", ":Gitsigns stage_hunk", "[h]unk [s]tage") - keymap({"v","n"}, "hr", ":Gitsigns reset_hunk", "[h]unk [r]eset") - keymap("n", "hS", "Gitsigns stage_buffer", "[h]unk [S]tage buffer") - keymap("n", "hu", "Gitsigns undo_stage_hunk", "[h]unk [u]ndo stage") - keymap("n", "hR", "Gitsigns reset_buffer", "[h]unk [R]eset buffer") - keymap("n", "hp", "Gitsigns preview_hunk", "[h]unk [p]review") - keymap("n", "ht", "Gitsigns toggle_deleted", "[h]unk [t]oggle deleted") - end - }, - }, - - { - "nvim-treesitter/playground", - requires = "nvim-treesitter/nvim-treesitter", - cmd = "TSPlaygroundToggle" - }, - - { - "sindrets/diffview.nvim", - dependencies = {"nvim-lua/plenary.nvim"}, - opts = { - enhanced_diff_hl = true - }, - keys = { - {"gdo", "DiffviewOpen", desc = "[g]it [d]iff [o]pen" }, - {"gdc", "DiffviewClose", desc = "[g]it [d]iff [c]pen" } - } - }, - - { - "vim-scripts/DoxygenToolkit.vim", - cmd = "Dox", - config = function() - vim.g.DoxygenToolkit_startCommentTag = "/// " - vim.g.DoxygenToolkit_interCommentTag = "/// " - vim.g.DoxygenToolkit_endCommentTag = "" - vim.g.DoxygenToolkit_startCommentBlock = "// " - vim.g.DoxygenToolkit_interCommentBlock = "// " - vim.g.DoxygenToolkit_endCommentBlock = "" - end - }, - - { - "SmiteshP/nvim-navbuddy", - dependencies = { - "neovim/nvim-lspconfig", - "SmiteshP/nvim-navic", - "MunifTanjim/nui.nvim", - "nvim-telescope/telescope.nvim" - }, - keys = { - {"o", "Navbuddy", desc="Navbuddy"} - }, - opts = { - window = { - border = "rounded", - size = "60%", - position = "50%", - sections = { - left = { size = "20%" }, - mid = { size = "40%" }, - right = { preview = "leaf" } - }, - }, - node_markers = { enabled = true }, - use_default_mappings = true, - lsp = { auto_attach = true } - } - }, - - { - "m-gail/escape.nvim", - keys = { - {mode="v", "q", function(...) return require("escape").escape(...) end, desc="Escape [q]uotes"} - } - }, - - -- { - -- "rest-nvim/rest.nvim", - -- requires = { "nvim-lua/plenary.nvim" }, - -- keys = { - -- {mode="n", "n", "RestNvim", desc = "Run HTTP request under cursor"} - -- } - -- }, - - { - "jenterkin/vim-autosource", - config = function() - local data = vim.fn.stdpath("data") - vim.g.autosource_hashdir = data .. "/vim-autosource/hashes" - end - }, - - { - "fedepujol/move.nvim", - config = function() - local opts = { noremap = true, silent = true } - vim.keymap.set("v", "", ":MoveBlock(1)", opts) - vim.keymap.set("v", "", ":MoveBlock(-1)", opts) - end, - }, - - { - "srcery-colors/srcery-vim", - priority = 1000, - config = function() - vim.cmd.colorscheme("srcery") - end, - }, - - { - "rafcamlet/nvim-luapad", - cmd = {"Luapad", "LuaRun"}, - init = function() - local pattern = "^/tmp/.*/%d+_Luapad%.lua$" - vim.api.nvim_create_autocmd("FileType", { - group = vim.api.nvim_create_augroup("LuaPadFiletype", {clear=true}), - callback = function(data) - if data.file:match(pattern) then - vim.bo[data.buf].filetype = "lua.luapad" - end - end - }) - end - }, - - -- { - -- -- Set lualine as statusline - -- "nvim-lualine/lualine.nvim", - -- -- See `:help lualine.txt` - -- opts = { - -- options = { - -- icons_enabled = false, - -- theme = "srcery", - -- component_separators = "|", - -- section_separators = "", - -- }, - -- }, - -- }, - - -- { - -- -- Add indentation guides even on blank lines - -- "lukas-reineke/indent-blankline.nvim", - -- -- Enable `lukas-reineke/indent-blankline.nvim` - -- -- See `:help indent_blankline.txt` - -- main = "ibl", - -- opts = {}, - -- }, - - -- "gc" to comment visual regions/lines - { "numToStr/Comment.nvim", opts = {} }, - - { - "norcalli/nvim-colorizer.lua", - lazy = false, - config = function() - require("colorizer").setup( - nil, - { - RGB = true, - RRGGBB = true, - names = false, - RRGGBBAA = true, - rgb_fn = true, - hsl_fn = true, - css = false, - css_fn = false, - mode = "background" - } - ) - end - }, - - { - -- Highlight, edit, and navigate code - "nvim-treesitter/nvim-treesitter", - dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" }, - build = ":TSUpdate", - }, - - { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - keys = { - { "e", "Neotree toggle", desc = "Toggle file tre[e]" }, - { "f", "Neotree reveal toggle", desc = "Toggle file tre[e] (file)" }, - }, - config = function() - require("neo-tree").setup({ - window = { - mappings = { - [""] = "open_vsplit", - [""] = "open_split" - } - }, - filesystem = { - group_empty_dirs = false - } - }) - end - }, - - -- TODO: When updating throws an error - -- { - -- "m00qek/baleia.nvim", - -- tag = "v1.2.0", - -- config = function() - -- local baleia = require("baleia").setup() - -- vim.api.nvim_create_user_command("BaleiaColorize", function() - -- baleia.once(vim.api.nvim_get_current_buf()) - -- end, { }) - -- end, - -- keys = { - -- { id = "[A]NSI [C]olorize", "ac", "BaleiaColorize", desc = "Colorize ANSI codes" } - -- } - -- }, - - - -- TODO: Setup DAP - -- use { "mfussenegger/nvim-dap", config_name="dap" } - -- use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require("dapui").setup()]] } - -- use "simrat39/rust-tools.nvim" - -- use { - -- "theHamsta/nvim-dap-virtual-text", - -- requires = {"mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter"}, - -- config=[[require("nvim-dap-virtual-text")]] - -- } - - { - "s1n7ax/nvim-window-picker", - name = "window-picker", - event = "VeryLazy", - version = "2.*", - config = function() - require("window-picker").setup() - end - }, - - { - dir = "personal/cmacro-align", - config = function() require("personal.cmacro-align").load() end - }, - - { - dir = "personal/add-include-guard", - config = function() require("personal.add-include-guard").load() end, - cmd = "AddIncludeGuard" - }, - - { - dir = "personal/plugin-dev", - config = function() require("personal.plugin-dev").load() end, - }, - - { - dir = "personal/uci", - config = function() require("personal.uci").load() end, - ft="uci" - }, - - { - dir = "personal/disable-builtin", - lazy = false, - config = function() require("personal.disable-builtin").load() end, - }, - - { import = "plugins" } -}, {}) - -- [[ Setting options ]] --- See `:help vim.o` +-- See `:help vim.opt` -- Enable auto reload of changed files -do - vim.o.autoread = true - -- TODO: - -- local autoreload_grp = vim.api.nvim_create_augroup("AutoReload", { clear = true }) - -- vim.api.nvim_create_autocmd({"FocusGained","BufEnter","CursorHold","CursorHoldI"}, { - -- group = autoreload_grp, - -- pattern = {"*"}, - -- callback = function() - -- -- TODO: Port this to lua - -- vim.cmd [[if mode() != "c" | checktime | endif]] - -- end - -- }) - -- vim.api.nvim_create_autocmd({"FileChangedShellPost"}, { - -- group = autoreload_grp, - -- pattern = {"*"}, - -- callback = function() - -- -- TODO: Port this to lua - -- vim.cmd [[echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]] - -- end - -- }) - -- autocmd("auto-reload", { - -- [[FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != "c" | checktime | endif]], - -- [[FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]] - -- }, true) -end +vim.o.autoread = true -do - -- TODO: Use nvim API - vim.cmd.syntax("on") - vim.cmd.filetype("plugin on") +-- Make line numbers default +vim.opt.number = true +vim.opt.relativenumber = true - vim.g.zig_fmt_autosave = 0 +-- Enable mouse mode, can be useful for resizing splits for example! +vim.opt.mouse = 'a' - -- Folding options - vim.o.foldmethod = "indent" - vim.o.foldlevelstart = 99 +-- Don't show the mode, since it's already in the status line +vim.opt.showmode = false - -- Identation/Tab settings - local tab_size = 2 - vim.bo.expandtab = true - vim.bo.smartindent = true - vim.bo.shiftwidth = tab_size - vim.bo.tabstop = tab_size - vim.bo.softtabstop = tab_size +-- Sync clipboard between OS and Neovim. +-- Schedule the setting after `UiEnter` because it can increase startup-time. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' +end) - vim.g.python_ident = { - disable_parentheses_indenting = false, - closed_paren_align_last_line = false, - searchpair_timeout = 150, - continue = "shiftwidth()", - open_paren = "shiftwidth()", - nested_paren = "shiftwidth()" - } +-- Enable break indent +vim.opt.breakindent = true - -- Set highlight on search - vim.o.hlsearch = false - vim.o.ignorecase = true - vim.o.smartcase = true - vim.o.incsearch = true - vim.o.inccommand = "nosplit" +-- Folding options +vim.o.foldmethod = 'indent' +vim.o.foldlevelstart = 99 - -- Always keep at least 8 blank lines below the last line - vim.o.scrolloff = 8 +-- Save undo history +vim.opt.undofile = true - -- Show 110 marker column - vim.o.colorcolumn = "110" +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +vim.opt.ignorecase = true +vim.opt.smartcase = true - -- How whitespace characters should be displayed - vim.o.listchars = [[space:.,eol:$,tab:>-]] +-- Keep signcolumn on by default +vim.opt.signcolumn = 'yes' - -- Show current mode that you are in - vim.o.showmode = true +-- Decrease update time +vim.opt.updatetime = 250 - -- Add a bit of transparency to windows - vim.o.pumblend = 15 - vim.cmd.highlight("PmenuSel blend=0") -- TODO: use nvim API +-- Decrease mapped sequence wait time +-- Displays which-key popup sooner +vim.opt.timeoutlen = 300 - -- Keep non-visible files open - vim.o.hidden = true +-- Configure how new splits should be opened +vim.opt.splitright = true +vim.opt.splitbelow = true - -- Make line numbers default + relative numbers - vim.wo.number = true - vim.wo.relativenumber = true +-- Sets how neovim will display certain whitespace characters in the editor. +-- See `:help 'list'` +-- and `:help 'listchars'` +vim.opt.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } - -- Enable mouse mode - vim.o.mouse = "a" +-- Preview substitutions live, as you type! +vim.opt.inccommand = 'split' - -- Skip redrawing window while executing macro - vim.o.lazyredraw = true +-- Show which line your cursor is on +vim.opt.cursorline = true - -- Sync clipboard between OS and Neovim. - vim.o.clipboard = "unnamedplus" +-- Minimal number of screen lines to keep above and below the cursor. +vim.opt.scrolloff = 10 - -- Enable break indent - vim.o.breakindent = true +-- Remove cmdline when not used +vim.o.cmdheight = 0 - -- Save undo history - vim.o.undofile = true +-- Show 110 marker column +vim.o.colorcolumn = '110' - -- Keep signcolumn on by default - vim.wo.signcolumn = "yes" +-- Keep non-visible files open +vim.o.hidden = true - -- Decrease update time - vim.o.updatetime = 250 - vim.o.timeoutlen = 300 +-- Skip redrawing window while executing macro +vim.o.lazyredraw = true - -- Place splits below and to the right by default - vim.o.splitbelow = true - vim.o.splitright = true - - -- By default don"t wrap text - vim.o.wrap = false - - -- Remove cmdline when not used - vim.o.cmdheight = 0 - - -- Set completeopt to have a better completion experience - vim.o.completeopt = "menuone,noselect" - - -- Scale neovide a bit - if vim.g.neovide then - vim.g.neovide_scale_factor = 0.75 - vim.g.neovide_hide_mouse_when_typing = true - end - - -- Stop neovim from confusing tools like inotify - -- Because by default, it will rename the original and then delete it. - -- This confuses inotify to think the file doesn't exist and stops trackign it. - vim.o.backupcopy = "yes" -end +-- Place splits below and to the right by default +vim.o.splitbelow = true +vim.o.splitright = true -- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` -do - -- Keymaps for better default experience - -- See `:help vim.keymap.set()` - vim.keymap.set({ "n", "v" }, "", "", { silent = true }) +-- Clear highlights on search when pressing in normal mode +-- See `:help hlsearch` +vim.keymap.set('n', '', 'nohlsearch') - -- Remap for dealing with word wrap - vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) - vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +-- Diagnostic keymaps +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) - -- Better movement between tabs - vim.keymap.set("n", "", ":tabprevious", { silent = true }) - vim.keymap.set("n", "", ":tabnext", { silent = true }) +-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier +-- for people to discover. Otherwise, you normally need to press , which +-- is not what someone will guess without a bit more experience. +-- +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping +-- or just use to exit terminal mode +vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - -- Better indenting - vim.keymap.set("v", "<", "", ">gv") +-- Keybinds to make split navigation easier. +-- Use CTRL+ to switch between windows +-- +-- See `:help wincmd` for a list of all window commands +vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - -- Save file - vim.keymap.set("n", "", ":w", { silent = true }) +-- Better indenting +vim.keymap.set('v', '<', '', '>gv') - -- Disable Ex mode - vim.keymap.set("n", "Q", "") +-- Save file +vim.keymap.set('n', '', ':w', { silent = true }) - -- Window movement - vim.g.tmux_navigator_no_mappings = 1 - vim.keymap.set("n", "", ":TmuxNavigateLeft", { noremap = true, silent=true }) - vim.keymap.set("n", "", ":TmuxNavigateDown", { noremap = true, silent=true }) - vim.keymap.set("n", "", ":TmuxNavigateUp", { noremap = true, silent=true }) - vim.keymap.set("n", "", ":TmuxNavigateRight", { noremap = true, silent=true }) +-- Disable Ex mode +vim.keymap.set('n', 'Q', '') - -- Resize windows - vim.keymap.set('n', '', ':resize -2', { silent = true }) - vim.keymap.set('n', '', ':resize +2', { silent = true}) - vim.keymap.set('n', '', ':vertical resize -2', { silent = true }) - vim.keymap.set('n', '', ':vertical resize +2', { silent = true }) -end +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` --- Change c file comment string -vim.api.nvim_create_autocmd("FileType", { - group = vim.api.nvim_create_augroup("set-c-commentstring", { clear = true }), - pattern = {"c", "cc", "cpp", "h", "hpp"}, - callback = function(data) - vim.api.nvim_buf_set_option(data.buf, "commentstring", "// %s") - end -}) - --- Override `ft` for .h files to `c` -vim.api.nvim_create_autocmd("FileType", { - group = vim.api.nvim_create_augroup("override-c-header-ft", { clear = true }), - pattern = "cpp", - callback = function(data) - if data.file:match("%.h$") then - vim.api.nvim_buf_set_option(data.buf, "ft", "c") - end - end -}) - --- Remove trailing whitespace -vim.api.nvim_create_autocmd({ "BufWritePre" }, { - pattern = { "*" }, - command = [[%s/\s\+$//e]], -}) - --- Move between windows easier in terminal windows -function _G.set_terminal_keymaps() - local opts = {buffer = 0} - vim.keymap.set("t", "", [[]], opts) - vim.keymap.set("t", "", [[wincmd h]], opts) - vim.keymap.set("t", "", [[wincmd j]], opts) - vim.keymap.set("t", "", [[wincmd k]], opts) - vim.keymap.set("t", "", [[wincmd l]], opts) -end -vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()") - --- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) -vim.api.nvim_create_autocmd("TextYankPost", { +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), callback = function() vim.highlight.on_yank() end, - group = highlight_group, - pattern = "*", +}) + +-- Override `ft` for .h files to `c` +vim.api.nvim_create_autocmd('FileType', { + group = vim.api.nvim_create_augroup('override-c-header-ft', { clear = true }), + pattern = 'cpp', + callback = function(data) + if data.file:match '%.h$' then + vim.api.nvim_buf_set_option_value(data.buf, 'ft', 'c') + end + end, }) -- Add abbreviation for != => ~= in lua files -vim.api.nvim_create_autocmd("BufEnter", { - group = vim.api.nvim_create_augroup("MyTermOpen", { clear = true }), - pattern = "*.lua", - callback = function() - vim.api.nvim_cmd({ cmd = "abb", args = {"", "!=", "~="}}, {}) - end +vim.api.nvim_create_autocmd('BufEnter', { + group = vim.api.nvim_create_augroup('MyTermOpen', { clear = true }), + pattern = '*.lua', + callback = function() + vim.api.nvim_cmd({ cmd = 'abb', args = { '', '!=', '~=' } }, {}) + end, }) --- [[ Configure Treesitter ]] --- See `:help nvim-treesitter` --- Defer Treesitter setup after first render to improve startup time of "nvim {filename}" -vim.defer_fn(function() - require("nvim-treesitter.configs").setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { "c", "cpp", "go", "lua", "python", "rust", "tsx", "javascript", "typescript", "vimdoc", "vim" }, - - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, - - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = "", - node_decremental = "", - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["aa"] = "@parameter.outer", - ["ia"] = "@parameter.inner", - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]m"] = "@function.outer", - ["]]"] = "@class.outer", - }, - goto_next_end = { - ["]M"] = "@function.outer", - ["]["] = "@class.outer", - }, - goto_previous_start = { - ["[m"] = "@function.outer", - ["[["] = "@class.outer", - }, - goto_previous_end = { - ["[M"] = "@function.outer", - ["[]"] = "@class.outer", - }, - }, - swap = { - enable = true, - swap_next = { - ["a"] = "@parameter.inner", - }, - swap_previous = { - ["A"] = "@parameter.inner", - }, - }, - }, - } -end, 0) - --- Diagnostic keymaps -vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) -vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) -vim.keymap.set("n", "dm", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) -vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) - --- [[ Configure LSP ]] --- This function gets run when an LSP connects to a particular buffer. -local on_attach = function(_, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don"t have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = "LSP: " .. desc - end - - vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) +-- [[ Install `lazy.nvim` plugin manager ]] +-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = 'https://github.com/folke/lazy.nvim.git' + local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } + if vim.v.shell_error ~= 0 then + error('Error cloning lazy.nvim:\n' .. out) end +end ---@diagnostic disable-next-line: undefined-field +vim.opt.rtp:prepend(lazypath) - nmap("rn", vim.lsp.buf.rename, "[R]e[n]ame") - nmap("ca", vim.lsp.buf.code_action, "[C]ode [A]ction") +-- [[ Configure and install plugins ]] +require('lazy').setup({ + -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', - nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") - nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") - nmap("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") - nmap("D", vim.lsp.buf.type_definition, "Type [D]efinition") - nmap("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") - nmap("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") + -- Smooth scrolling + 'psliwka/vim-smoothie', - -- See `:help K` for why this keymap - nmap("K", vim.lsp.buf.hover, "Hover Documentation") - --nmap("", vim.lsp.buf.signature_help, "Signature Documentation") + -- Select indented text + 'michaeljsmith/vim-indent-object', - -- Lesser used LSP functionality - nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") - nmap("wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") - nmap("wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") - nmap("wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, "[W]orkspace [L]ist Folders") + -- Detect and apply editorconfig settings + 'editorconfig/editorconfig-vim', - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) - vim.lsp.buf.format() - end, { desc = "Format current buffer with LSP" }) -end + -- Better quickfix window + 'kevinhwang91/nvim-bqf', --- document existing key chains --- require("which-key").register({ --- ["c"] = { name = "[C]ode", _ = "which_key_ignore" }, --- ["d"] = { name = "[D]ocument", _ = "which_key_ignore" }, --- ["g"] = { name = "[G]it", _ = "which_key_ignore" }, --- ["h"] = { name = "More git", _ = "which_key_ignore" }, --- ["r"] = { name = "[R]ename", _ = "which_key_ignore" }, --- ["s"] = { name = "[S]earch", _ = "which_key_ignore" }, --- ["w"] = { name = "[W]orkspace", _ = "which_key_ignore" }, --- }) - --- Enable the following language servers --- Feel free to add/remove any LSPs that you want here. They will automatically be installed. --- --- Add any additional override configuration in the following tables. They will be passed to --- the `settings` field of the server config. You must look up that documentation yourself. --- --- If you want to override the default filetypes that your language server will attach to you can --- define the property "filetypes" to the map in question. -local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- tsserver = {}, - -- html = { filetypes = { "html", "twig", "hbs"} }, - - lua_ls = { - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, + { + 'backdround/global-note.nvim', + config = function() + require('global-note').setup {} + end, + keys = { + { + 'n', + function() + require('global-note').toggle_note() + end, + desc = 'Toggle [N]otes', + }, }, }, -} --- Setup neovim lua configuration -require("neodev").setup() + { + 'kdheepak/lazygit.nvim', + keys = { + { 'g', 'LazyGit', desc = 'Open lazygit' }, + }, + }, --- nvim-cmp supports additional completion capabilities, so broadcast that to servers -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) + { + 'stevearc/dressing.nvim', + dependencies = { 'nvim-telescope/telescope.nvim' }, + opts = { + select = { + get_config = function(opts) + opts = opts or {} + local cfg = { + telescope = { + layout_config = { + -- width = 120, + -- height = 60, + width = 0.87, + height = 0.80, + }, + }, + } + if opts.kind == 'legendary.nvim' then + cfg.telescope.sorter = require('telescope.sorters').fuzzy_with_index_bias {} + end + return cfg + end, + }, + }, + }, --- Ensure the servers above are installed -local mason_lspconfig = require "mason-lspconfig" + { 'tikhomirov/vim-glsl', ft = 'glsl' }, -mason_lspconfig.setup { - ensure_installed = vim.tbl_keys(servers), -} + { + 'nvim-treesitter/playground', + requires = 'nvim-treesitter/nvim-treesitter', + cmd = 'TSPlaygroundToggle', + }, -mason_lspconfig.setup_handlers { - function(server_name) - require("lspconfig")[server_name].setup { - capabilities = capabilities, - on_attach = on_attach, - settings = servers[server_name], - filetypes = (servers[server_name] or {}).filetypes, - } - end -} - --- [[ Configure nvim-cmp ]] --- See `:help cmp` -local cmp = require "cmp" -local luasnip = require "luasnip" -require("luasnip.loaders.from_vscode").lazy_load() -luasnip.config.setup {} - -local lspkind = require("lspkind") -lspkind.init() - -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) + { + 'vim-scripts/DoxygenToolkit.vim', + cmd = 'Dox', + config = function() + vim.g.DoxygenToolkit_startCommentTag = '/// ' + vim.g.DoxygenToolkit_interCommentTag = '/// ' + vim.g.DoxygenToolkit_endCommentTag = '' + vim.g.DoxygenToolkit_startCommentBlock = '// ' + vim.g.DoxygenToolkit_interCommentBlock = '// ' + vim.g.DoxygenToolkit_endCommentBlock = '' end, }, - mapping = cmp.mapping.preset.insert { - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete {}, - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, + + { + 'fedepujol/move.nvim', + opts = {}, + config = function() + local opts = { noremap = true, silent = true } + vim.keymap.set('v', '', ':MoveBlock(1)', opts) + vim.keymap.set('v', '', ':MoveBlock(-1)', opts) + end, + }, + + { + 'norcalli/nvim-colorizer.lua', + lazy = false, + config = function() + require('colorizer').setup(nil, { + RGB = true, + RRGGBB = true, + names = false, + RRGGBBAA = true, + rgb_fn = true, + hsl_fn = true, + css = false, + css_fn = false, + mode = 'background', + }) + end, + }, + + { + 'stevearc/oil.nvim', + opts = { + default_file_explorer = true, + skip_confirm_for_simple_edits = true, }, - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), + -- Optional dependencies + -- dependencies = { { "echasnovski/mini.icons", opts = {} } }, + dependencies = { 'nvim-tree/nvim-web-devicons' }, -- use if prefer nvim-web-devicons }, - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "path" }, - { name = "buffer", max_item_count = 10, keyword_length = 5 }, - }, - formatting = { - format = lspkind.cmp_format{ with_text = true } - }, - experimental = { - native_menu = false, - ghost_text = true, - } -} --- Use buffer source for `/`. -cmp.setup.cmdline("/", { - sources = { - { name = "buffer" } - } + { + 'unblevable/quick-scope', + init = function() + -- Trigger a highlight in the appropriate direction when pressing these keys: + vim.g.qs_highlight_on_keys = { 'f', 'F', 't', 'T' } + vim.g.qs_max_chars = 150 + end, + }, + + { + dir = '~/.config/nvim/lua/personal/uci', + config = function() + require('personal.uci.init').load() + end, + ft = 'uci', + }, + + { + dir = '~/.config/nvim/lua/personal/uci', + config = function() + require('personal.add-include-guard').load() + end, + cmd = 'AddIncludeGuard', + }, + + { + 'folke/zen-mode.nvim', + opts = { + plugins = { + gitsigns = { enabled = true }, + }, + }, + }, + + -- Here is a more advanced example where we pass configuration + -- options to `gitsigns.nvim`. This is equivalent to the following Lua: + -- require('gitsigns').setup({ ... }) + -- + -- See `:help gitsigns` to understand what the configuration keys do + { -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + }, + }, + + -- + -- This is often very useful to both group configuration, as well as handle + -- lazy loading plugins that don't need to be loaded immediately at startup. + -- + -- For example, in the following configuration, we use: + -- event = 'VimEnter' + -- + -- which loads which-key before all the UI elements are loaded. Events can be + -- normal autocommands events (`:help autocmd-events`). + -- + -- Then, because we use the `opts` key (recommended), the configuration runs + -- after the plugin has been loaded as `require(MODULE).setup(opts)`. + + { -- Useful plugin to show you pending keybinds. + 'folke/which-key.nvim', + event = 'VimEnter', -- Sets the loading event to 'VimEnter' + opts = { + icons = { + -- set icon mappings to true if you have a Nerd Font + mappings = vim.g.have_nerd_font, + -- If you are using a Nerd Font: set icons.keys to an empty table which will use the + -- default which-key.nvim defined Nerd Font icons, otherwise define a string table + keys = vim.g.have_nerd_font and {} or { + Up = ' ', + Down = ' ', + Left = ' ', + Right = ' ', + C = ' ', + M = ' ', + D = ' ', + S = ' ', + CR = ' ', + Esc = ' ', + ScrollWheelDown = ' ', + ScrollWheelUp = ' ', + NL = ' ', + BS = ' ', + Space = ' ', + Tab = ' ', + F1 = '', + F2 = '', + F3 = '', + F4 = '', + F5 = '', + F6 = '', + F7 = '', + F8 = '', + F9 = '', + F10 = '', + F11 = '', + F12 = '', + }, + }, + + -- Document existing key chains + spec = { + { 'c', group = '[C]ode', mode = { 'n', 'x' } }, + { 'd', group = '[D]ocument' }, + { 'r', group = '[R]ename' }, + { 's', group = '[S]earch' }, + { 'w', group = '[W]orkspace' }, + { 't', group = '[T]oggle' }, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + }, + }, + }, + + -- + -- The dependencies are proper plugin specifications as well - anything + -- you do for a plugin at the top level, you can do for a dependency. + -- + -- Use the `dependencies` key to specify the dependencies of a particular plugin + + { -- Fuzzy Finder (files, lsp, etc) + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { -- If encountering errors, see telescope-fzf-native README for installation instructions + 'nvim-telescope/telescope-fzf-native.nvim', + + -- `build` is used to run some command when the plugin is installed/updated. + -- This is only run then, not every time Neovim starts up. + build = 'make', + + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + + -- Useful for getting pretty icons, but requires a Nerd Font. + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + config = function() + -- Telescope is a fuzzy finder that comes with a lot of different things that + -- it can fuzzy find! It's more than just a "file finder", it can search + -- many different aspects of Neovim, your workspace, LSP, and more! + -- + -- The easiest way to use Telescope, is to start by doing something like: + -- :Telescope help_tags + -- + -- After running this command, a window will open up and you're able to + -- type in the prompt window. You'll see a list of `help_tags` options and + -- a corresponding preview of the help. + -- + -- Two important keymaps to use while in Telescope are: + -- - Insert mode: + -- - Normal mode: ? + -- + -- This opens a window that shows you all of the keymaps for the current + -- Telescope picker. This is really useful to discover what Telescope can + -- do as well as how to actually do it! + + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + -- You can put your default mappings / updates / etc. in here + -- All the info you're looking for is in `:help telescope.setup()` + -- + -- defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, + -- pickers = {} + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + -- Enable Telescope extensions if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + + -- Slightly advanced example of overriding default behavior and theme + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to Telescope to change the theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set('n', 's/', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) + + -- Shortcut for searching your Neovim configuration files + vim.keymap.set('n', 'sn', function() + builtin.find_files { cwd = vim.fn.stdpath 'config' } + end, { desc = '[S]earch [N]eovim files' }) + end, + }, + + -- LSP Plugins + { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = 'luvit-meta/library', words = { 'vim%.uv' } }, + }, + }, + }, + { 'Bilal2453/luvit-meta', lazy = true }, + { + -- Main LSP Configuration + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs and related tools to stdpath for Neovim + { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + + -- Useful status updates for LSP. + { 'j-hui/fidget.nvim', opts = {} }, + + -- Allows extra capabilities provided by nvim-cmp + 'hrsh7th/cmp-nvim-lsp', + }, + config = function() + -- Brief aside: **What is LSP?** + -- + -- LSP is an initialism you've probably heard, but might not understand what it is. + -- + -- LSP stands for Language Server Protocol. It's a protocol that helps editors + -- and language tooling communicate in a standardized fashion. + -- + -- In general, you have a "server" which is some tool built to understand a particular + -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers + -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone + -- processes that communicate with some "client" - in this case, Neovim! + -- + -- LSP provides Neovim with features like: + -- - Go to definition + -- - Find references + -- - Autocompletion + -- - Symbol Search + -- - and more! + -- + -- Thus, Language Servers are external tools that must be installed separately from + -- Neovim. This is where `mason` and related plugins come into play. + -- + -- If you're wondering about lsp vs treesitter, you can check out the wonderfully + -- and elegantly composed help section, `:help lsp-vs-treesitter` + + -- This function gets run when an LSP attaches to a particular buffer. + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + + -- Find references for the word under your cursor. + map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map('rn', vim.lsp.buf.rename, '[R]e[n]ame') + + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then + map('th', function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) + end, '[T]oggle Inlay [H]ints') + end + end, + }) + + -- Change diagnostic symbols in the sign column (gutter) + if vim.g.have_nerd_font then + local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' } + local diagnostic_signs = {} + for type, icon in pairs(signs) do + diagnostic_signs[vim.diagnostic.severity[type]] = icon + end + vim.diagnostic.config { signs = { text = diagnostic_signs } } + end + + -- LSP servers and clients are able to communicate to each other what features they support. + -- By default, Neovim doesn't support everything that is in the LSP specification. + -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`ts_ls`) will work just fine + -- ts_ls = {}, + -- + + lua_ls = { + -- cmd = { ... }, + -- filetypes = { ... }, + -- capabilities = {}, + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + } + + -- Ensure the servers and tools above are installed + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu. + require('mason').setup() + + -- You can add other tools here that you want Mason to install + -- for you, so that they are available from within Neovim. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'stylua', -- Used to format Lua code + }) + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + require('mason-lspconfig').setup { + handlers = { + function(server_name) + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for ts_ls) + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + } + end, + }, + + { -- Autoformat + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { + 'f', + function() + require('conform').format { async = true, lsp_format = 'fallback' } + end, + mode = '', + desc = '[F]ormat buffer', + }, + }, + opts = { + notify_on_error = false, + format_on_save = function(bufnr) + -- Disable "format_on_save lsp_fallback" for languages that don't + -- have a well standardized coding style. You can add additional + -- languages here or re-enable it for the disabled ones. + local disable_filetypes = { c = true, cpp = true } + local lsp_format_opt + if disable_filetypes[vim.bo[bufnr].filetype] then + lsp_format_opt = 'never' + else + lsp_format_opt = 'fallback' + end + return { + timeout_ms = 500, + lsp_format = lsp_format_opt, + } + end, + formatters_by_ft = { + lua = { 'stylua' }, + -- Conform can also run multiple formatters sequentially + -- python = { "isort", "black" }, + -- + -- You can use 'stop_after_first' to run the first available formatter from the list + -- javascript = { "prettierd", "prettier", stop_after_first = true }, + }, + }, + }, + + { -- Autocompletion + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + { + 'L3MON4D3/LuaSnip', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + -- { + -- 'rafamadriz/friendly-snippets', + -- config = function() + -- require('luasnip.loaders.from_vscode').lazy_load() + -- end, + -- }, + }, + }, + 'saadparwaiz1/cmp_luasnip', + + -- Adds other completion capabilities. + -- nvim-cmp does not ship with all sources by default. They are split + -- into multiple repos for maintenance purposes. + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + }, + config = function() + -- See `:help cmp` + local cmp = require 'cmp' + local luasnip = require 'luasnip' + luasnip.config.setup {} + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = 'menu,menuone,noinsert' }, + + -- For an understanding of why these mappings were + -- chosen, you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! + mapping = cmp.mapping.preset.insert { + -- Select the [n]ext item + [''] = cmp.mapping.select_next_item(), + -- Select the [p]revious item + [''] = cmp.mapping.select_prev_item(), + + -- Scroll the documentation window [b]ack / [f]orward + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + + -- Accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + [''] = cmp.mapping.confirm { select = true }, + + -- If you prefer more traditional completion keymaps, + -- you can uncomment the following lines + --[''] = cmp.mapping.confirm { select = true }, + --[''] = cmp.mapping.select_next_item(), + --[''] = cmp.mapping.select_prev_item(), + + -- Manually trigger a completion from nvim-cmp. + -- Generally you don't need this, because nvim-cmp will display + -- completions whenever it has completion options available. + [''] = cmp.mapping.complete {}, + + -- Think of as moving to the right of your snippet expansion. + -- So if you have a snippet that's like: + -- function $name($args) + -- $body + -- end + -- + -- will move you to the right of each of the expansion locations. + -- is similar, except moving you backwards. + [''] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { 'i', 's' }), + + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + }, + sources = { + { + name = 'lazydev', + -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it + group_index = 0, + }, + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + }, + } + end, + }, + + { + 'srcery-colors/srcery-vim', + priority = 1000, + config = function() + vim.cmd.colorscheme 'srcery' + end, + }, + + -- Highlight todo, notes, etc in comments + { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + + { -- Collection of various small independent plugins/modules + 'echasnovski/mini.nvim', + config = function() + -- Better Around/Inside textobjects + -- + -- Examples: + -- - va) - [V]isually select [A]round [)]paren + -- - yinq - [Y]ank [I]nside [N]ext [Q]uote + -- - ci' - [C]hange [I]nside [']quote + require('mini.ai').setup { n_lines = 500 } + + -- Add/delete/replace surroundings (brackets, quotes, etc.) + -- + -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren + -- - sd' - [S]urround [D]elete [']quotes + -- - sr)' - [S]urround [R]eplace [)] ['] + require('mini.surround').setup() + + local function recording_macro() + local reg = vim.api.nvim_call_function('reg_recording', {}) + if reg ~= '' then + return '@' .. reg + else + return '' + end + end + + local statusline = require 'mini.statusline' + statusline.setup { + content = { + active = function() + local mode, mode_hl = MiniStatusline.section_mode { trunc_width = 120 } + local git = MiniStatusline.section_git { trunc_width = 40 } + local diff = MiniStatusline.section_diff { trunc_width = 75 } + local diagnostics = MiniStatusline.section_diagnostics { trunc_width = 75 } + local lsp = MiniStatusline.section_lsp { trunc_width = 75 } + local filename = MiniStatusline.section_filename { trunc_width = 140 } + local fileinfo = MiniStatusline.section_fileinfo { trunc_width = 120 } + local location = MiniStatusline.section_location { trunc_width = 75 } + local search = MiniStatusline.section_searchcount { trunc_width = 75 } + + return MiniStatusline.combine_groups { + { hl = mode_hl, strings = { mode } }, + { hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp, recording_macro() } }, + '%<', -- Mark general truncate point + { hl = 'MiniStatuslineFilename', strings = { filename } }, + '%=', -- End left alignment + { hl = 'MiniStatuslineFileinfo', strings = { fileinfo } }, + { hl = mode_hl, strings = { search, location } }, + } + end, + }, + -- set use_icons to true if you have a Nerd Font + use_icons = vim.g.have_nerd_font, + } + + -- You can configure sections in the statusline by overriding their + -- default behavior. For example, here we set the section for + -- cursor location to LINE:COLUMN + ---@diagnostic disable-next-line: duplicate-set-field + statusline.section_location = function() + return '%2l:%-2v' + end + + -- ... and there is more! + -- Check out: https://github.com/echasnovski/mini.nvim + end, + }, + { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + main = 'nvim-treesitter.configs', -- Sets main module to use for opts + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + opts = { + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + -- Autoinstall languages that are not installed + auto_install = true, + highlight = { + enable = true, + -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. + -- If you are experiencing weird indenting issues, add the language to + -- the list of additional_vim_regex_highlighting and disabled languages for indent. + additional_vim_regex_highlighting = { 'ruby' }, + }, + indent = { enable = true, disable = { 'ruby' } }, + }, + -- There are additional nvim-treesitter modules that you can use to interact + -- with nvim-treesitter. You should go explore a few and see what interests you: + -- + -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + }, + + -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the + -- init.lua. If you want these files, they are in the repository, so you can just download them and + -- place them in the correct locations. + + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + -- require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.gitsigns', +}, { + ui = { + -- If you are using a Nerd Font: set icons to an empty table which will use the + -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table + icons = vim.g.have_nerd_font and {} or { + cmd = '⌘', + config = '🛠', + event = '📅', + ft = '📂', + init = '⚙', + keys = '🗝', + plugin = '🔌', + runtime = '💻', + require = '🌙', + source = '📄', + start = '🚀', + task = '📌', + lazy = '💤 ', + }, + }, }) -require("move").setup({}) - -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json index ec1a499..d323edb 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,67 +1,50 @@ { - "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "DoxygenToolkit.vim": { "branch": "master", "commit": "afd8663d36d2ec19d26befdb10e89e912d26bbd3" }, - "LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, - "based.nvim": { "branch": "main", "commit": "886e63bab99714bada17d2a0e300841250d2daa6" }, - "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "LuaSnip": { "branch": "master", "commit": "33b06d72d220aa56a7ce80a0dd6f06c70cd82b9d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "compiler-explorer.nvim": { "branch": "master", "commit": "ee8e7a2808bdad67cd2acb61b5c9ffa7735c7ec9" }, - "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, - "dressing.nvim": { "branch": "master", "commit": "1b7921eecc65af1baf8ac1dc06f0794934cbcfb2" }, - "editorconfig-vim": { "branch": "master", "commit": "8b7da79e9daee7a3f3a8d4fe29886b9756305aff" }, - "escape.nvim": { "branch": "main", "commit": "ab474f9322a215d552f56e98be4f932be0f4169f" }, - "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, - "friendly-snippets": { "branch": "main", "commit": "00ba9dd3df89509f95437b8d595553707c46d5ea" }, - "git-blame.nvim": { "branch": "master", "commit": "2883a7460f611c2705b23f12d58d398d5ce6ec00" }, - "gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "f4e8837878fc5712d053ba3091a73d27d96a09e2" }, + "dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" }, + "editorconfig-vim": { "branch": "master", "commit": "3c2813f2566d9392ff3614248c5db43c3fda9d5f" }, + "fidget.nvim": { "branch": "main", "commit": "9238947645ce17d96f30842e61ba81147185b657" }, + "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, "global-note.nvim": { "branch": "main", "commit": "1e0d4bba425d971ed3ce40d182c574a25507115c" }, - "lazy.nvim": { "branch": "main", "commit": "1159bdccd8910a0fd0914b24d6c3d186689023d9" }, - "lazygit.nvim": { "branch": "main", "commit": "56760339a81cd1540d5a72fd9d93010a2677b55d" }, - "lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" }, - "lspkind-nvim": { "branch": "master", "commit": "59c3f419af48a2ffb2320cea85e44e5a95f71664" }, - "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, + "indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" }, + "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" }, + "lazygit.nvim": { "branch": "main", "commit": "77a0d42943d8265271e6e6beaed72da54eeb17e7" }, + "luvit-meta": { "branch": "main", "commit": "57d464c4acb5c2e66bd4145060f5dc9e96a7bbb7" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "8e46de9241d3997927af12196bd8faa0ed08c29a" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.nvim": { "branch": "main", "commit": "7ebfab26d77a4b9b05aaae565907e7fa4b2ee154" }, "move.nvim": { "branch": "main", "commit": "cccbd4ea9049ca5f99f025ffaddb7392359c7d6a" }, - "neo-tree.nvim": { "branch": "v3.x", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, - "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, - "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, - "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-cmp": { "branch": "main", "commit": "98e8b9d593a5547c126a39212d6f5e954a2d85dd" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-lspconfig": { "branch": "master", "commit": "dcf511d53fae9675c6fde4241d94b2daaa5e0cd5" }, - "nvim-luapad": { "branch": "master", "commit": "176686eb616a5ada5dfc748f2b5109194bbe8a71" }, - "nvim-navbuddy": { "branch": "master", "commit": "f22bac988f2dd073601d75ba39ea5636ab6e38cb" }, - "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, - "nvim-treesitter": { "branch": "master", "commit": "4f04fb7027ce786ac4adfd1c629ca40aea96ffec" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "b91c98afa6c42819aea6cbc1ba38272f5456a5cf" }, - "nvim-web-devicons": { "branch": "master", "commit": "56f17def81478e406e3a8ec4aa727558e79786f3" }, + "nvim-dap": { "branch": "master", "commit": "7e48a80551e0b8fd7e34436d74243de7ae1ec397" }, + "nvim-dap-go": { "branch": "main", "commit": "6aa88167ea1224bcef578e8c7160fe8afbb44848" }, + "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, + "nvim-lint": { "branch": "master", "commit": "1fea92f1d9908eaa5eb8bafe08b4293d7aadaa55" }, + "nvim-lspconfig": { "branch": "master", "commit": "040001d85e9190a904d0e35ef5774633e14d8475" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-treesitter": { "branch": "master", "commit": "fa915a30c5cdf1d18129e9ef6ac2ee0fa799904f" }, + "nvim-web-devicons": { "branch": "master", "commit": "0eb18da56e2ba6ba24de7130a12bcc4e31ad11cb" }, + "oil.nvim": { "branch": "master", "commit": "dba037598843973b8c54bc5ce0318db4a0da439d" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "quick-scope": { "branch": "master", "commit": "4d35d3b2bc6794666353dcc241b2680bd560416f" }, "srcery-vim": { "branch": "master", "commit": "fa2242a3dd81804468241c0a8ebb32266c33fa60" }, - "tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" }, - "targets.vim": { "branch": "master", "commit": "6325416da8f89992b005db3e4517aaef0242602e" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, - "tidy.nvim": { "branch": "main", "commit": "58fcc63de53840fa78946e4161e8883e67213f92" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, - "toggleterm.nvim": { "branch": "main", "commit": "137d06fb103952a0fb567882bb8527e2f92d327d" }, - "vim-autosource": { "branch": "main", "commit": "569440e157d6eb37fb098dfe95252533553a56f5" }, - "vim-blade": { "branch": "master", "commit": "9534101808cc320eef003129a40cab04b026a20c" }, - "vim-eunuch": { "branch": "master", "commit": "8fb3904be27b6b60d086f87c2570085902414069" }, "vim-glsl": { "branch": "master", "commit": "40dd0b143ef93f3930a8a409f60c1bb85e28b727" }, "vim-indent-object": { "branch": "master", "commit": "8ab36d5ec2a3a60468437a95e142ce994df598c6" }, - "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, "vim-smoothie": { "branch": "master", "commit": "df1e324e9f3395c630c1c523d0555a01d2eb1b7e" }, - "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-tmux-navigator": { "branch": "master", "commit": "a9b52e7d36114d40350099f254b5f299a35df978" }, - "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }, - "window-picker": { "branch": "main", "commit": "41cfaa428577c53552200a404ae9b3a0b5719706" }, - "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" }, - "zig-tools.nvim": { "branch": "master", "commit": "78a85278fe5d480da2f01df4db898757d7e953b5" } + "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" }, + "zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" } } diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua new file mode 100644 index 0000000..b59d086 --- /dev/null +++ b/lua/kickstart/health.lua @@ -0,0 +1,52 @@ +--[[ +-- +-- This file is not required for your own configuration, +-- but helps people determine if their system is setup correctly. +-- +--]] + +local check_version = function() + local verstr = tostring(vim.version()) + if not vim.version.ge then + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) + return + end + + if vim.version.ge(vim.version(), '0.10-dev') then + vim.health.ok(string.format("Neovim version is: '%s'", verstr)) + else + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) + end +end + +local check_external_reqs = function() + -- Basic utils: `git`, `make`, `unzip` + for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do + local is_executable = vim.fn.executable(exe) == 1 + if is_executable then + vim.health.ok(string.format("Found executable: '%s'", exe)) + else + vim.health.warn(string.format("Could not find executable: '%s'", exe)) + end + end + + return true +end + +return { + check = function() + vim.health.start 'kickstart.nvim' + + vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth` + + Fix only warnings for plugins and languages you intend to use. + Mason will give warnings for languages that are not installed. + You do not need to install, unless you want to use those languages!]] + + local uv = vim.uv or vim.loop + vim.health.info('System Information: ' .. vim.inspect(uv.os_uname())) + + check_version() + check_external_reqs() + end, +} diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua new file mode 100644 index 0000000..87a7e5f --- /dev/null +++ b/lua/kickstart/plugins/autopairs.lua @@ -0,0 +1,16 @@ +-- autopairs +-- https://github.com/windwp/nvim-autopairs + +return { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + -- Optional dependency + dependencies = { 'hrsh7th/nvim-cmp' }, + config = function() + require('nvim-autopairs').setup {} + -- If you want to automatically add `(` after selecting a function or method + local cmp_autopairs = require 'nvim-autopairs.completion.cmp' + local cmp = require 'cmp' + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + end, +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua new file mode 100644 index 0000000..753cb0c --- /dev/null +++ b/lua/kickstart/plugins/debug.lua @@ -0,0 +1,148 @@ +-- debug.lua +-- +-- Shows how to use the DAP plugin to debug your code. +-- +-- Primarily focused on configuring the debugger for Go, but can +-- be extended to other languages as well. That's why it's called +-- kickstart.nvim and not kitchen-sink.nvim ;) + +return { + -- NOTE: Yes, you can install new plugins here! + 'mfussenegger/nvim-dap', + -- NOTE: And you can specify dependencies as well + dependencies = { + -- Creates a beautiful debugger UI + 'rcarriga/nvim-dap-ui', + + -- Required dependency for nvim-dap-ui + 'nvim-neotest/nvim-nio', + + -- Installs the debug adapters for you + 'williamboman/mason.nvim', + 'jay-babu/mason-nvim-dap.nvim', + + -- Add your own debuggers here + 'leoluz/nvim-dap-go', + }, + keys = { + -- Basic debugging keymaps, feel free to change to your liking! + { + '', + function() + require('dap').continue() + end, + desc = 'Debug: Start/Continue', + }, + { + '', + function() + require('dap').step_into() + end, + desc = 'Debug: Step Into', + }, + { + '', + function() + require('dap').step_over() + end, + desc = 'Debug: Step Over', + }, + { + '', + function() + require('dap').step_out() + end, + desc = 'Debug: Step Out', + }, + { + 'b', + function() + require('dap').toggle_breakpoint() + end, + desc = 'Debug: Toggle Breakpoint', + }, + { + 'B', + function() + require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, + desc = 'Debug: Set Breakpoint', + }, + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + { + '', + function() + require('dapui').toggle() + end, + desc = 'Debug: See last session result.', + }, + }, + config = function() + local dap = require 'dap' + local dapui = require 'dapui' + + require('mason-nvim-dap').setup { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_installation = true, + + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + handlers = {}, + + -- You'll need to check that you have the required things installed + -- online, please don't ask me how to install them :) + ensure_installed = { + -- Update this to ensure that you have the debuggers for the langs you want + 'delve', + }, + } + + -- Dap UI setup + -- For more information, see |:help nvim-dap-ui| + dapui.setup { + -- Set icons to characters that are more likely to work in every terminal. + -- Feel free to remove or use ones that you like more! :) + -- Don't feel like these are good choices. + icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', + }, + }, + } + + -- Change breakpoint icons + -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) + -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) + -- local breakpoint_icons = vim.g.have_nerd_font + -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } + -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } + -- for type, icon in pairs(breakpoint_icons) do + -- local tp = 'Dap' .. type + -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' + -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) + -- end + + dap.listeners.after.event_initialized['dapui_config'] = dapui.open + dap.listeners.before.event_terminated['dapui_config'] = dapui.close + dap.listeners.before.event_exited['dapui_config'] = dapui.close + + -- Install golang specific config + require('dap-go').setup { + delve = { + -- On Windows delve must be run attached or it crashes. + -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring + detached = vim.fn.has 'win32' == 0, + }, + } + end, +} diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua new file mode 100644 index 0000000..2d56875 --- /dev/null +++ b/lua/kickstart/plugins/gitsigns.lua @@ -0,0 +1,59 @@ +-- Adds git related signs to the gutter, as well as utilities for managing changes + +return { + { + 'lewis6991/gitsigns.nvim', + opts = { + on_attach = function(bufnr) + local gitsigns = require 'gitsigns' + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal { ']c', bang = true } + else + gitsigns.nav_hunk 'next' + end + end, { desc = 'Jump to next git [c]hange' }) + + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal { '[c', bang = true } + else + gitsigns.nav_hunk 'prev' + end + end, { desc = 'Jump to previous git [c]hange' }) + + -- Actions + -- visual mode + map('v', 'hs', function() + gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'git [s]tage hunk' }) + map('v', 'hr', function() + gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'git [r]eset hunk' }) + -- normal mode + map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) + map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) + map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) + map('n', 'hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) + map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) + map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) + map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) + map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) + map('n', 'hD', function() + gitsigns.diffthis '@' + end, { desc = 'git [D]iff against last commit' }) + -- Toggles + map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) + map('n', 'tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) + end, + }, + }, +} diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/kickstart/plugins/indent_line.lua new file mode 100644 index 0000000..ed7f269 --- /dev/null +++ b/lua/kickstart/plugins/indent_line.lua @@ -0,0 +1,9 @@ +return { + { -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help ibl` + main = 'ibl', + opts = {}, + }, +} diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua new file mode 100644 index 0000000..907c6bf --- /dev/null +++ b/lua/kickstart/plugins/lint.lua @@ -0,0 +1,60 @@ +return { + + { -- Linting + 'mfussenegger/nvim-lint', + event = { 'BufReadPre', 'BufNewFile' }, + config = function() + local lint = require 'lint' + lint.linters_by_ft = { + markdown = { 'markdownlint' }, + } + + -- To allow other plugins to add linters to require('lint').linters_by_ft, + -- instead set linters_by_ft like this: + -- lint.linters_by_ft = lint.linters_by_ft or {} + -- lint.linters_by_ft['markdown'] = { 'markdownlint' } + -- + -- However, note that this will enable a set of default linters, + -- which will cause errors unless these tools are available: + -- { + -- clojure = { "clj-kondo" }, + -- dockerfile = { "hadolint" }, + -- inko = { "inko" }, + -- janet = { "janet" }, + -- json = { "jsonlint" }, + -- markdown = { "vale" }, + -- rst = { "vale" }, + -- ruby = { "ruby" }, + -- terraform = { "tflint" }, + -- text = { "vale" } + -- } + -- + -- You can disable the default linters by setting their filetypes to nil: + -- lint.linters_by_ft['clojure'] = nil + -- lint.linters_by_ft['dockerfile'] = nil + -- lint.linters_by_ft['inko'] = nil + -- lint.linters_by_ft['janet'] = nil + -- lint.linters_by_ft['json'] = nil + -- lint.linters_by_ft['markdown'] = nil + -- lint.linters_by_ft['rst'] = nil + -- lint.linters_by_ft['ruby'] = nil + -- lint.linters_by_ft['terraform'] = nil + -- lint.linters_by_ft['text'] = nil + + -- Create autocommand which carries out the actual linting + -- on the specified events. + local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { + group = lint_augroup, + callback = function() + -- Only run the linter in buffers that you can modify in order to + -- avoid superfluous noise, notably within the handy LSP pop-ups that + -- describe the hovered symbol using Markdown. + if vim.opt_local.modifiable:get() then + lint.try_lint() + end + end, + }) + end, + }, +} diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua new file mode 100644 index 0000000..bd44226 --- /dev/null +++ b/lua/kickstart/plugins/neo-tree.lua @@ -0,0 +1,25 @@ +-- Neo-tree is a Neovim plugin to browse the file system +-- https://github.com/nvim-neo-tree/neo-tree.nvim + +return { + 'nvim-neo-tree/neo-tree.nvim', + version = '*', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended + 'MunifTanjim/nui.nvim', + }, + cmd = 'Neotree', + keys = { + { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, + }, + opts = { + filesystem = { + window = { + mappings = { + ['\\'] = 'close_window', + }, + }, + }, + }, +} diff --git a/lua/old_dap_cfg.lua b/lua/old_dap_cfg.lua deleted file mode 100644 index 4b23707..0000000 --- a/lua/old_dap_cfg.lua +++ /dev/null @@ -1,36 +0,0 @@ -local dap = require('dap') -dap.adapters.lldb = { - type = 'executable', - command = '/usr/bin/lldb-vscode', - name = 'lldb' -} - -dap.configurations.cpp = { - { - name = 'Launch', - type = 'lldb', - request = 'launch', - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - end, - cwd = '${workspaceFolder}', - stopOnEntry = false, - args = {}, - - -- 💀 - -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: - -- - -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope - -- - -- Otherwise you might get the following error: - -- - -- Error on launch: Failed to attach to the target process - -- - -- But you should be aware of the implications: - -- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html - -- runInTerminal = false, - }, -} - -dap.configurations.c = dap.configurations.cpp -dap.configurations.rust = dap.configurations.cpp diff --git a/lua/personal/add-include-guard.lua b/lua/personal/add-include-guard/init.lua similarity index 52% rename from lua/personal/add-include-guard.lua rename to lua/personal/add-include-guard/init.lua index db82b41..117971d 100644 --- a/lua/personal/add-include-guard.lua +++ b/lua/personal/add-include-guard/init.lua @@ -3,18 +3,18 @@ local M = {} function M.load() -- TODO: Make it work with buffer which don't have a filename yet - vim.api.nvim_create_user_command("AddIncludeGuard", function(data) + vim.api.nvim_create_user_command('AddIncludeGuard', function(data) local bufnr = vim.api.nvim_get_current_buf() - local name_pattern = data.fargs[1] or "%s_" + local name_pattern = data.fargs[1] or '%s_' local function formatName(filename) - local parts = vim.split(filename, "[/\\]", {trimempty=true}) + local parts = vim.split(filename, '[/\\]', { trimempty = true }) local last_part = parts[#parts] - local ext = last_part:match("%.([^%.]+)$") - local name = last_part:gsub("%.[^%.]+$", "") + local ext = last_part:match '%.([^%.]+)$' + local name = last_part:gsub('%.[^%.]+$', '') - if ext == "h" or ext == "hpp" then - name = name.."_H" + if ext == 'h' or ext == 'hpp' then + name = name .. '_H' end return name_pattern:format(name:upper()) @@ -24,16 +24,16 @@ function M.load() local guard_name = formatName(buf_filename) vim.api.nvim_buf_set_lines(bufnr, 0, 0, false, { - "#ifndef "..guard_name, - "#define "..guard_name, - "" + '#ifndef ' .. guard_name, + '#define ' .. guard_name, + '', }) vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { - "", - "#endif //"..guard_name + '', + '#endif //' .. guard_name, }) - end, { nargs="?" }) + end, { nargs = '?' }) end return M diff --git a/lua/personal/cmacro-align.lua b/lua/personal/cmacro-align.lua deleted file mode 100644 index a464e5a..0000000 --- a/lua/personal/cmacro-align.lua +++ /dev/null @@ -1,111 +0,0 @@ -local M = {} - -local ts = vim.treesitter - -local function get_ast_root(bufnr) - local tree = ts.get_parser(bufnr, "c"):parse() - return tree[1]:root() -end - - -local function do_lines_match(lines1, lines2) - if #lines1 ~= lines2 then - return false - end - for i, line1 in ipairs(lines1) do - if line1 ~= lines2[i] then - return false - end - end - return true -end - -local function format_macros() - local query = ts.query.parse("c", [[ - (preproc_function_def value: (preproc_arg) @macro_def) - (preproc_def value: (preproc_arg) @macro_def) - ]]) - - local capture_lookup = {} - for id, name in ipairs(query.captures) do - capture_lookup[name] = id - end - - local bufnr = vim.api.nvim_get_current_buf() - local winnr = vim.api.nvim_get_current_win() - - for _, match in query:iter_matches(get_ast_root(bufnr), bufnr, 0, -1) do - local macro_def_node = match[capture_lookup.macro_def] - -- local class_name = ts.get_node_text(class_node, bufnr) - local start_line = macro_def_node:start() - local end_line = macro_def_node:end_() - - local lines = vim.api.nvim_buf_get_lines(bufnr, start_line, end_line+1, false) - local tabstop = tonumber(vim.bo[bufnr].tabstop) or 8 - - local new_lines = {} - for i, line in ipairs(lines) do - lines[i] = line:match("^(.-)%s*[\\]?$") - new_lines[i] = lines[i] - end - - while true do - local last_line = new_lines[#lines] - if not last_line then break end - if last_line:match("^%s*//") or last_line:match("^%s*/%*") or last_line:match("^%s*$") then - table.remove(lines, #lines) - end_line = end_line - 1 - else - break - end - end - - if #new_lines > 2 then - local line_length = 0 - do - local textwidth = vim.bo[bufnr].textwidth - if textwidth and textwidth ~= "" then - line_length = tonumber(textwidth) - end - - if line_length <= 0 then - local colorcolum = vim.wo[winnr].colorcolumn - if colorcolum and colorcolum ~= "" then - line_length = tonumber(colorcolum) - end - end - - if line_length <= 0 then - for _, line in ipairs(new_lines) do - line_length = math.max(line_length, #line+2) - end - end - end - - for i = 1, #new_lines-1 do - local line = new_lines[i] - local length = #(line:gsub("\t", (" "):rep(tabstop))) - lines[i] = line .. (" "):rep(line_length - length-2) .. " \\" - end - - if not do_lines_match(lines, new_lines) then - vim.api.nvim_buf_set_lines(bufnr, start_line, end_line+1, false, lines) - end - end - end -end - -function M.load() - local group = vim.api.nvim_create_augroup("UpdateCMacro", { clear = true }) - for _, cmd in ipairs{"InsertLeavePre", "BufWritePre"} do - vim.api.nvim_create_autocmd(cmd, { - group = group, - pattern = {"*.c", "*.h", "*.cpp", "*.hpp", "*.cc"}, - callback = function (data) - format_macros() - end - }) - end -end - -return M diff --git a/lua/personal/disable-builtin.lua b/lua/personal/disable-builtin.lua deleted file mode 100644 index 4c17f65..0000000 --- a/lua/personal/disable-builtin.lua +++ /dev/null @@ -1,17 +0,0 @@ -local M = {} - -function M.load() - local disabled_built_ins = { - 'matchit', - 'netrw', - 'netrwPlugin', - 'netrwSettings', - 'netrwFileHandlers', - } - - for _, name in ipairs(disabled_built_ins) do - vim.g['loaded_' .. name] = 1 - end -end - -return M diff --git a/lua/personal/plugin-dev.lua b/lua/personal/plugin-dev.lua deleted file mode 100644 index 1cb3b37..0000000 --- a/lua/personal/plugin-dev.lua +++ /dev/null @@ -1,11 +0,0 @@ -local M = {} - -function M.load() - vim.keymap.set("n", "x", ":w:source %", { silent = true }) - - function _G.P(...) - print(vim.inspect(...)) - end -end - -return M diff --git a/lua/personal/uci.lua b/lua/personal/uci/init.lua similarity index 81% rename from lua/personal/uci.lua rename to lua/personal/uci/init.lua index bb17e8a..95056a5 100644 --- a/lua/personal/uci.lua +++ b/lua/personal/uci/init.lua @@ -2,16 +2,16 @@ local M = {} function M.load() -- Setup tree sitter - local parser_config = require("nvim-treesitter.parsers").get_parser_configs() + local parser_config = require('nvim-treesitter.parsers').get_parser_configs() parser_config.uci = { install_info = { - url = "git@rpuzonas.com:rpuzonas/tree-sitter-uci.git", - files = {"src/parser.c"}, - branch = "main", + url = 'git@rpuzonas.com:rpuzonas/tree-sitter-uci.git', + files = { 'src/parser.c' }, + branch = 'main', generate_requires_npm = false, requires_generate_from_grammar = false, }, - filetype = "uci", + filetype = 'uci', } -- Determine UCI filetype by contents of file. @@ -33,7 +33,8 @@ function M.load() } } }) - ]]-- + ]] + -- end return M diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua deleted file mode 100644 index 1732974..0000000 --- a/lua/plugins/lualine.lua +++ /dev/null @@ -1,168 +0,0 @@ - -local empty = require('lualine.component'):extend() -function empty:draw(default_highlight) - self.status = '' - self.applied_separator = '' - self:apply_highlights(default_highlight) - self:apply_section_separators() - return self.status -end - --- Put proper separators and gaps between components in sections -local function process_sections(sections) - local bg = vim.g.srcery_xgray1 - - for name, section in pairs(sections) do - local left = name:sub(9, 10) < 'x' - for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do - table.insert(section, pos * 2, { empty, color = { fg = bg, bg = bg } }) - end - for id, comp in ipairs(section) do - if type(comp) ~= 'table' then - comp = { comp } - section[id] = comp - end - comp.separator = left and { right = '' } or { left = '' } - end - end - return sections -end - -local function search_result() - local last_search = vim.fn.getreg('/') - if not last_search or last_search == '' then - return '' - end - local searchcount = vim.fn.searchcount { maxcount = 9999 } - if searchcount.total == 0 then - return '' - end - return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' -end - -local function recording_macro() - local reg = vim.api.nvim_call_function("reg_recording", {}) - if reg ~= "" then - return "@" .. reg - else - return "" - end -end - -local function modified() - if vim.bo.modified then - return '+' - elseif vim.bo.modifiable == false or vim.bo.readonly == true then - return '-' - end - return '' -end - - -return { - "nvim-lualine/lualine.nvim", - dependencies = {"nvim-tree/nvim-web-devicons"}, - config = function() - local bg = vim.g.srcery_xgray1 - - local colors = { - red = vim.g.srcery_red, - grey = vim.g.srcery_black, - black = vim.g.srcery_hard_black, - white = vim.g.srcery_bright_white, - light_green = vim.g.srcery_bright_green, - orange = vim.g.srcery_orange, - green = vim.g.srcery_green, - } - - local theme = { - normal = { - a = { fg = colors.white, bg = colors.black }, - b = { fg = colors.white, bg = colors.grey }, - c = { fg = colors.black, bg = bg }, - z = { fg = colors.white, bg = colors.black }, - }, - insert = { a = { fg = colors.black, bg = colors.light_green } }, - visual = { a = { fg = colors.black, bg = colors.orange } }, - replace = { a = { fg = colors.black, bg = colors.green } }, - } - - local extensions = {"man", "quickfix"} - if pcall(require, "neo-tree") then - table.insert(extensions, "neo-tree") - end - if pcall(require, "luapad.statusline") then - table.insert(extensions, { - sections = process_sections { - lualine_a = {"mode"}, - lualine_b = { - { - "diagnostics", - source = { "nvim" }, - sections = { "error" }, - diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, - }, - { - "diagnostics", - source = { "nvim" }, - sections = { "warn" }, - diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, - }, - { recording_macro, color = { bg = colors.orange } } - }, - lualine_y = { search_result, "filetype" }, - lualine_z = { "%l:%c", "%p%%/%L" }, - }, - filetypes = {"lua.luapad"} - }) - end - - require("lualine").setup { - options = { - icons_enabled = true, - theme = theme, - component_separators = "", - section_separators = { left = "", right = "" }, - globalstatus = true - }, - sections = process_sections { - lualine_a = { "mode" }, - lualine_b = { - "branch", - "diff", - { - "diagnostics", - source = { "nvim" }, - sections = { "error" }, - diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, - }, - { - "diagnostics", - source = { "nvim" }, - sections = { "warn" }, - diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, - }, - { "filename", file_status = false, path = 1 }, - { modified, color = { bg = colors.red } }, - { "%w", cond = function() return vim.wo.previewwindow end }, - { "%r", cond = function() return vim.bo.readonly end }, - { "%q", cond = function() return vim.bo.buftype == "quickfix" end }, - { recording_macro, color = { bg = colors.orange } } - }, - lualine_c = {}, - lualine_x = {}, - lualine_y = { search_result, "filetype" }, - lualine_z = { "%l:%c", "%p%%/%L" }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {}, - lualine_x = {}, - lualine_y = {}, - lualine_z = {}, - }, - extensions = extensions - } - end -} diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua deleted file mode 100644 index 7a07661..0000000 --- a/lua/plugins/luasnip.lua +++ /dev/null @@ -1,89 +0,0 @@ -local function capture(cmd, raw) - local f = assert(io.popen(cmd, 'r')) - local s = assert(f:read('*a')) - f:close() - if raw then return s end - s = string.gsub(s, '^%s+', '') - s = string.gsub(s, '%s+$', '') - s = string.gsub(s, '[\n\r]+', ' ') - return s -end - -return { - "L3MON4D3/LuaSnip", - config = function() - local ls = require("luasnip") - local s = ls.snippet - local sn = ls.snippet_node - local fmt = require("luasnip.extras.fmt").fmt - local t = ls.text_node - local i = ls.insert_node - local f = ls.function_node - local c = ls.choice_node - local d = ls.dynamic_node - - local function getCurrentYear() - return os.date("%Y") - end - - local function getGitUsername() - local stdout = capture("git config user.name") - if stdout == "" then return nil end - return stdout - end - - -- ls.config.set_config { - -- history = true, - -- updateevents = "TextChanged,TextChangedI", - -- enable_autosnippets = true - -- } - - -- vim.keymap.set({"i", "s"}, "", function() - -- if ls.expand_or_jumpable() then - -- ls.expand_or_jump() - -- end - -- end, { silent = true }) - - -- vim.keymap.set({ "i", "s" }, "", function() - -- if ls.jumpable(-1) then ls.jump(-1) end - -- end, { silent = -1 }) - - -- vim.keymap.set({"i"}, "", function() - -- if ls.choice_active() then ls.change_choice(1) end - -- end) - - ls.add_snippets("all", { - s("MIT", { - t({"The MIT License (MIT)", "Copyright © "}), - f(getCurrentYear, {}), - t(" "), - d(1, function() - return sn(nil, { - i(1, getGitUsername() or "") - }) - end, {}), - t{ - "", - "", - "Permission is hereby granted, free of charge, to any person obtaining a copy of", - "this software and associated documentation files (the “Software”), to deal in", - "the Software without restriction, including without limitation the rights to", - "use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies", - "of the Software, and to permit persons to whom the Software is furnished to do", - "so, subject to the following conditions:", - "", - "The above copyright notice and this permission notice shall be included in all", - "copies or substantial portions of the Software.", - "", - "THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", - "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", - "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", - "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", - "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", - "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE", - "SOFTWARE.", - } - }) - }) - end -} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua deleted file mode 100644 index 7fda25c..0000000 --- a/lua/plugins/telescope.lua +++ /dev/null @@ -1,154 +0,0 @@ -local telescope = require('telescope') -local actions = require('telescope.actions') -local builtin = require('telescope.builtin') - --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` --- require('telescope').setup { --- defaults = { --- mappings = { --- i = { --- [''] = false, --- [''] = false, --- }, --- }, --- }, --- } - --- Enable telescope fzf native, if installed --- pcall(require('telescope').load_extension, 'fzf') - --- See `:help telescope.builtin` --- vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) --- vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) --- vim.keymap.set('n', '/', function() --- -- You can pass additional configuration to telescope to change theme, layout, etc. --- require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { --- winblend = 10, --- previewer = false, --- }) --- end, { desc = '[/] Fuzzily search in current buffer' }) - --- vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) --- vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) --- vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) --- vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) --- vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) --- vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) --- vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) - --- Falling back to find_files if git_files can't find a .git directory -local function project_files(opts) - opts = opts or {} - if not opts.prompt_title then - opts.prompt_title = "Project files" - end - local ok = pcall(builtin.git_files, opts) - if not ok then builtin.find_files(opts) end -end - -local function get_vtext() - local prev_regv = vim.fn.getreg('v') - vim.cmd('noau normal! "vy"') - local text = vim.fn.getreg('v') - vim.fn.setreg("v", prev_regv) - - text = string.gsub(text, "\n", "") - if #text > 0 then - return text - else - return "" - end -end - -local function escape_sed_symbols(text) - return text:gsub("[.()%[%]]", "\\%1") -end - -return { - "nvim-telescope/telescope.nvim", - tag = "0.1.5", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons", - "nvim-telescope/telescope-ui-select.nvim", - { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - cond = function() return vim.fn.executable('make') == 1 end, - } - }, - config = function() - telescope.setup{ - defaults = { - vimgrep_arguments = { - "rg", - "-L", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - }, - prompt_prefix = "  ", - selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "ascending", - layout_strategy = "horizontal", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.55, - results_width = 0.8, - }, - vertical = { mirror = false }, - width = 0.87, - height = 0.80, - preview_cutoff = 120, - }, - file_sorter = require("telescope.sorters").get_fuzzy_file, - file_ignore_patterns = { - "node_modules", - "package%-lock%.json", - "composer%.lock", - "vendor" - }, - generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - path_display = { "truncate" }, - color_devicons = true, - winblend = 0, - border = {}, - borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, - mappings = { - i = { [""] = actions.close } - }, - }, - pickers = { - live_grep = { disable_coordinates = true }, - colorscheme = { enable_preview = true } - }, - extensions = { - ["ui-select"] = { require("telescope.themes").get_dropdown {} } - } - } - - telescope.load_extension("ui-select") - pcall(telescope.load_extension, 'fzf') -- Enable telescope fzf native, if installed - - local keymap = vim.keymap.set - keymap("n", "", project_files, { desc = "Find [P]roject files" }) - keymap("n", "p", function() builtin.find_files() end, { desc = "[P] Find files" }) - keymap("n", "fw", function() builtin.live_grep() end, { desc = "[F]ind [W]ords" }) - keymap("v", "fw", function() builtin.live_grep{ default_text = escape_sed_symbols(get_vtext()) } end, { desc = "[F]ind [W]ords" }) - keymap("n", "fh", function() builtin.help_tags() end, { desc = "Find help tags" }) - end -} diff --git a/plugins/lldb-vscode.json b/plugins/lldb-vscode.json deleted file mode 100644 index ddcfc47..0000000 --- a/plugins/lldb-vscode.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "adapters": { - "lldb-vscode": { - "attach": { - "pidProperty": "pid", - "pidSelect": "none" - }, - "command": [ - "lldb-vscode" - ], - "env": { - "LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY": "YES" - }, - "name": "lldb" - } - } -}