From dd1d1bb6e9434e7d9aba335f39e3a37392a7688d Mon Sep 17 00:00:00 2001 From: Walter Jenkins Date: Wed, 16 Apr 2025 08:39:09 -0500 Subject: [PATCH] working --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 1 + .stylua.toml | 1 + init.lua | 1024 ++----------------------- lazyvim.json | 9 + lua/.DS_Store | Bin 0 -> 8196 bytes lua/core/keymaps.lua | 193 +++++ lua/core/options.lua | 63 ++ lua/core/snippets.lua | 45 ++ lua/core/ui.lua | 59 ++ lua/custom/plugins/init.lua | 5 - lua/kickstart/health.lua | 52 -- lua/kickstart/plugins/autopairs.lua | 16 - lua/kickstart/plugins/debug.lua | 148 ---- lua/kickstart/plugins/gitsigns.lua | 61 -- lua/kickstart/plugins/indent_line.lua | 9 - lua/kickstart/plugins/lint.lua | 60 -- lua/kickstart/plugins/neo-tree.lua | 25 - lua/plugins/aerial.lua | 26 + lua/plugins/autocompletion.lua | 143 ++++ lua/plugins/avante.lua | 28 + lua/plugins/better-comments.lua | 140 ++++ lua/plugins/bufferline.lua | 81 ++ lua/plugins/chatgpt.lua | 158 ++++ lua/plugins/comment.lua | 67 ++ lua/plugins/conform.lua | 17 + lua/plugins/database.lua | 50 ++ lua/plugins/debug.lua | 82 ++ lua/plugins/flash.lua | 16 + lua/plugins/gitsigns.lua | 21 + lua/plugins/harpoon.lua | 43 ++ lua/plugins/indent-blankline.lua | 25 + lua/plugins/lazygit.lua | 29 + lua/plugins/lsp-keymaps.lua | 209 +++++ lua/plugins/lsp.lua | 170 ++++ lua/plugins/lualine.lua | 116 +++ lua/plugins/misc.lua | 58 ++ lua/plugins/neo-tree.lua | 37 + lua/plugins/none-ls.lua | 55 ++ lua/plugins/snack.lua | 32 + lua/plugins/telescope.lua | 118 +++ lua/plugins/themes/nord.lua | 3 + lua/plugins/themes/onedark.lua | 101 +++ lua/plugins/themes/quantum.lua | 10 + lua/plugins/toggleterm.lua | 13 + lua/plugins/treesitter.lua | 108 +++ lua/plugins/vim-tmux-navigator.lua | 18 + lua/plugins/zellij.lua | 12 + nvim-troubleshooting.md | 9 + 49 files changed, 2444 insertions(+), 1322 deletions(-) create mode 100644 .DS_Store create mode 100644 lazyvim.json create mode 100644 lua/.DS_Store create mode 100644 lua/core/keymaps.lua create mode 100644 lua/core/options.lua create mode 100644 lua/core/snippets.lua create mode 100644 lua/core/ui.lua delete mode 100644 lua/custom/plugins/init.lua delete mode 100644 lua/kickstart/health.lua delete mode 100644 lua/kickstart/plugins/autopairs.lua delete mode 100644 lua/kickstart/plugins/debug.lua delete mode 100644 lua/kickstart/plugins/gitsigns.lua delete mode 100644 lua/kickstart/plugins/indent_line.lua delete mode 100644 lua/kickstart/plugins/lint.lua delete mode 100644 lua/kickstart/plugins/neo-tree.lua create mode 100644 lua/plugins/aerial.lua create mode 100644 lua/plugins/autocompletion.lua create mode 100644 lua/plugins/avante.lua create mode 100644 lua/plugins/better-comments.lua create mode 100644 lua/plugins/bufferline.lua create mode 100644 lua/plugins/chatgpt.lua create mode 100644 lua/plugins/comment.lua create mode 100644 lua/plugins/conform.lua create mode 100644 lua/plugins/database.lua create mode 100644 lua/plugins/debug.lua create mode 100644 lua/plugins/flash.lua create mode 100644 lua/plugins/gitsigns.lua create mode 100644 lua/plugins/harpoon.lua create mode 100644 lua/plugins/indent-blankline.lua create mode 100644 lua/plugins/lazygit.lua create mode 100644 lua/plugins/lsp-keymaps.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/misc.lua create mode 100644 lua/plugins/neo-tree.lua create mode 100644 lua/plugins/none-ls.lua create mode 100644 lua/plugins/snack.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/themes/nord.lua create mode 100644 lua/plugins/themes/onedark.lua create mode 100644 lua/plugins/themes/quantum.lua create mode 100644 lua/plugins/toggleterm.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/vim-tmux-navigator.lua create mode 100644 lua/plugins/zellij.lua create mode 100644 nvim-troubleshooting.md diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ec5640774c2bdf8c93b4251fff7fcc2b1e13768b GIT binary patch literal 6148 zcmeHK%}T>S5Z<*_6N-?7LXQhx3)WV&;w8lT0!H+pQWH`%7_+5G%%K!=))(?gd>&_Z zH()Vm5jz9B-~8@oKgj+t#<*8Rhm1LlF$)?ZN2Ni~-5A<1$%q`s$Yx<8L$E%=nTh>% zz;AD{gcU3Z%kSTx#97|&fAWo1dvj~svaF7E??1`X&x5?kykLHd)|He=SnEM}9Z$=N zvwJSnJc!fjTouI86jJVP;xv+_CyO-7RIRTAmTlV;r@L4Th9^BS7>$-au{a&{d*Wz# zyjWbeN#&cSlLOmIb_~|=4vJaLt3OW@nLdK2&aSfvi2-7O7$64Ln*nn! zSe^BzfmTlp5CaVi;Qk<>A-V=DjcV(F4zJG`ZzH0Bj&BJ>VbC>LX@m#}*QJ2El$$38 z*X7_BCeJlkY1HM6tC?XOGjsiT;c9m93zg2etC4zQfEZY1pruU*&;JYfWf~v(t0iO+ z1H`~TV}Q5E{@8;>nX~oB^6;z`&>o8hZP3)CUcHCSoHQP8i- Q0qG*32%(M`_yq>O0Mf8YfdBvi literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore index 005b535b..c558a5ac 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ nvim spell/ lazy-lock.json +.github/.DS_Store diff --git a/.stylua.toml b/.stylua.toml index 139e9397..8b05f16a 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -4,3 +4,4 @@ indent_type = "Spaces" indent_width = 2 quote_style = "AutoPreferSingle" call_parentheses = "None" +virtualedit = onemore diff --git a/init.lua b/init.lua index 4eae8e7d..d80bb7d9 100644 --- a/init.lua +++ b/init.lua @@ -1,957 +1,69 @@ ---[[ +require 'core.options' -- Load general options +require 'core.keymaps' -- Load general keymaps +require 'core.snippets' -- Custom code snippets -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your Neovim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) ---]] - --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' - --- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false - --- [[ Setting options ]] --- See `:help vim.opt` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` - --- Make line numbers default -vim.opt.number = true --- You can also add relative line numbers, to help with jumping. --- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true - --- Enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = 'a' - --- Don't show the mode, since it's already in the status line -vim.opt.showmode = false - --- 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) - --- Enable break indent -vim.opt.breakindent = true - --- Save undo history -vim.opt.undofile = true - --- Case-insensitive searching UNLESS \C or one or more capital letters in the search term -vim.opt.ignorecase = true -vim.opt.smartcase = true - --- Keep signcolumn on by default -vim.opt.signcolumn = 'yes' - --- Decrease update time -vim.opt.updatetime = 250 - --- Decrease mapped sequence wait time -vim.opt.timeoutlen = 300 - --- Configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = 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 = '␣' } - --- Preview substitutions live, as you type! -vim.opt.inccommand = 'split' - --- Show which line your cursor is on -vim.opt.cursorline = true - --- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 - --- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` - --- Clear highlights on search when pressing in normal mode --- See `:help hlsearch` -vim.keymap.set('n', '', 'nohlsearch') - --- Diagnostic keymaps -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) - --- 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' }) - --- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') - --- 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' }) - --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- 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, +-- Install package manager +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) +vim.filetype.add({ + extension = { + templ = "templ", + } }) --- [[ 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) +-- Import color theme based on environment variable NVIM_THEME +local default_color_scheme = 'quantum' +local env_var_nvim_theme = os.getenv 'NVIM_THEME' or default_color_scheme --- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- --- To update plugins you can run --- :Lazy update --- --- NOTE: Here is where you install your plugins. +-- Define a table of theme modules +local themes = { + quantum = 'plugins.themes.quantum', + nord = 'plugins.themes.nord', + onedark = 'plugins.themes.onedark', +} + +-- Setup plugins require('lazy').setup({ - -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). - 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + require(themes[env_var_nvim_theme]), + require 'core.ui', - -- NOTE: Plugins can also be added by using a table, - -- with the first argument being the link and the following - -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to force a plugin to be loaded. - -- - - -- 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 = '~' }, - }, - }, - }, - - -- NOTE: Plugins can also be configured to run Lua code when they are loaded. - -- - -- 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 = { - -- delay between pressing a key and opening which-key (milliseconds) - -- this setting is independent of vim.opt.timeoutlen - delay = 0, - 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' } }, - }, - }, - }, - - -- NOTE: Plugins can specify dependencies. - -- - -- 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 = '${3rd}/luv/library', words = { 'vim%.uv' } }, - }, - }, - }, - { - -- Main LSP Configuration - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs and related tools to stdpath for Neovim - -- Mason must be loaded before its dependents so we need to set it up here. - -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})` - { 'williamboman/mason.nvim', opts = {} }, - '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) - -- 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. - -- - -- 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 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 two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then - local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } - end, - }) - end - - -- 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. - -- - -- `mason` had to be setup earlier: to configure its options see the - -- `dependencies` table for `nvim-lspconfig` above. - -- - -- 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, - }, - - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. - init = function() - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' - - -- You can configure highlights by doing something like: - vim.cmd.hi 'Comment gui=none' - 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() - - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - -- set use_icons to true if you have a Nerd Font - statusline.setup { 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. - - -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for Kickstart - -- - -- Here are some example plugins that I've included in the Kickstart repository. - -- Uncomment any of the lines below to enable them (you will need to restart nvim). - -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps - - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` - -- This is the easiest way to modularize your config. - -- - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, - -- - -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` - -- Or use telescope! - -- In normal mode type `sh` then write `lazy.nvim-plugin` - -- you can continue same window with `sr` which resumes last telescope search + require 'plugins.aerial', + require 'plugins.flash', + require 'plugins.autocompletion', + require 'plugins.bufferline', + require 'plugins.comment', + require 'plugins.conform', + require 'plugins.database', + require 'plugins.debug', + require 'plugins.gitsigns', + require 'plugins.harpoon', + require 'plugins.lazygit', + require 'plugins.lsp', + require 'plugins.lualine', + require 'plugins.none-ls', + require 'plugins.indent-blankline', + require 'plugins.neo-tree', + require 'plugins.misc', + require 'plugins.snack', + require 'plugins.telescope', + require 'plugins.toggleterm', + require 'plugins.treesitter', + require 'plugins.vim-tmux-navigator', + require 'plugins.zellij', }, { 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 + -- If you have 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 = '🛠', @@ -970,5 +82,25 @@ require('lazy').setup({ }, }) +-- Function to check if a file exists +local function file_exists(file) + local f = io.open(file, 'r') + if f then + f:close() + return true + else + return false + end +end + +-- Path to the session file +local session_file = '.session.vim' + +-- Check if the session file exists in the current directory +if file_exists(session_file) then + -- Source the session file + vim.cmd('source ' .. session_file) +end + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lazyvim.json b/lazyvim.json new file mode 100644 index 00000000..a28f5eb9 --- /dev/null +++ b/lazyvim.json @@ -0,0 +1,9 @@ +{ + "extras": [ + + ], + "news": { + "NEWS.md": "10960" + }, + "version": 8 +} \ No newline at end of file diff --git a/lua/.DS_Store b/lua/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8d097b5f4e504518745726be97336748e10c681c GIT binary patch literal 8196 zcmeHMU2GIp6u#fIz>FPWS}7D{*_8z((AuT^v{1yQEkBjkBHPk!Dc1cN+L7r@-I?9; zlWGakh%xcs#3!Pnk3@|Ije)37CQ6K^A(2F4^g(>_i5E1Y=gyr4+Crjm?f%_*Y; zLr{UB0zn0W3Ir7hDsU@QfYxl@wRwjR*Vi{xN9yZFt0RZk*Tt$MYgVrt9aZGYXl>)J{{7~VWgioHz<(F8 znUnH*W@=KVQ)o_`JgJgIF{$&#q?9|#)S02~WKXZ!mozfAl`szJ{n~7YGHWGuXHG9r zM%@|P%nw;kzgC_}nVGzqa`nxo$p@2dwv)-(rn%F04A-!&o}{ZEaElX7a3y;kJLfig zll5y_-qCmIG?!7(TWCg_s)ApwW0+6l?ACJ*$!I(#l2lI4nipQOyr!;xV|+_%`$OZi zwekv8t(@CkFdQRo>OCnZqgz?S8t57^vhH9nmDh5OeTJS>lyX#eTB#v@yrOFUg1Z)m zLSoFdnBpwSeA;*{Z@34ws4Ru3r(T%V z(8_8GNOd|?ApbUFs}x0ZI`M5wxUovditE;E(ZP2aSkkxVkOuHddCPMuo%%M%ie<}I}h2CHC#LA zRpY_Mp->N>YI8QLXDR6gRr4!CiBOlUeM2#tVHFI*JUt5meK{KM5RW7pU*Vq!!I)QL zWlmA`C12x0Y#D2yHLa8FV>Ua&o@K|``|LD3!_KmE>;k*Ueqoo{uk1H=1tm~XfrVIt z8q^|&RoH+=Y{Vw)KqtDe8)@u^i6Pipo>(xe8D+E&a>|c>zCMNOh*|sgs~j=qJglz72DB@HnbDIljy-7^g+h}2JtAN z-9-T-IEX_yiYE!{PvaO~#LIXEui`jfC&Zt?TZH#_@GjoN$2g5M_ynJN$REdd_yIpo z!gBjWEaTEtEEf_v%e1Wl@)Q{`G3fTxO2lnf@%{gnn}7emJ(COWI;cQUfxlD%l(r;V znrP_FUTzZkB6K`L2XB1bn2=rwb$kf7d)sl6SN|}i^N8<@`*KW3@=*KNKLq^kAKbzE LAFTiXz4iZ39JX`u literal 0 HcmV?d00001 diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua new file mode 100644 index 00000000..812f257d --- /dev/null +++ b/lua/core/keymaps.lua @@ -0,0 +1,193 @@ +-- Keymaps for better default experience + +-- Set leader key +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- For conciseness +local opts = { noremap = true, silent = true } + +-- Disable the spacebar key's default behavior in Normal and Visual modes +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) + +-- Allow moving the cursor through wrapped lines with j, k +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 }) + +-- clear highlights +vim.keymap.set('n', '', ':noh', opts) + +-- save file +vim.keymap.set('n', '', ' w ', opts) + +-- save file without auto-formatting +vim.keymap.set('n', 'sn', 'noautocmd w ', opts) + +-- quit file +vim.keymap.set('n', '', ' q ', opts) + +-- delete single character without copying into register +vim.keymap.set('n', 'x', '"_x', opts) + +-- Vertical scroll and center +vim.keymap.set('n', '', 'zz', opts) +vim.keymap.set('n', '', 'zz', opts) + +-- Find and center +vim.keymap.set('n', 'n', 'nzzzv') +vim.keymap.set('n', 'N', 'Nzzzv') + +-- Resize with arrows +vim.keymap.set('n', '', ':resize -2', opts) +vim.keymap.set('n', '', ':resize +2', opts) +vim.keymap.set('n', '', ':vertical resize -2', opts) +vim.keymap.set('n', '', ':vertical resize +2', opts) + +-- Buffers +vim.keymap.set('n', '', ':bnext', opts) +vim.keymap.set('n', '', ':bprevious', opts) +vim.keymap.set('n', 'x', ':Bdelete!', opts) -- close buffer +vim.keymap.set('n', 'b', ' enew ', opts) -- new buffer + +-- Increment/decrement numbers +vim.keymap.set('n', '+', '', opts) -- increment +vim.keymap.set('n', '-', '', opts) -- decrement + +-- Window management +vim.keymap.set('n', 'v', 'v', opts) -- split window vertically +vim.keymap.set('n', 'h', 's', opts) -- split window horizontally +vim.keymap.set('n', 'se', '=', opts) -- make split windows equal width & height +vim.keymap.set('n', 'xs', ':close', opts) -- close current split window + +-- Navigate between splits +vim.keymap.set('n', '', ':wincmd k', opts) +vim.keymap.set('n', '', ':wincmd j', opts) +vim.keymap.set('n', '', ':wincmd h', opts) +vim.keymap.set('n', '', ':wincmd l', opts) + +-- Tabs +vim.keymap.set('n', 'to', ':tabnew', opts) -- open new tab +vim.keymap.set('n', 'tx', ':tabclose', opts) -- close current tab +vim.keymap.set('n', 'tn', ':tabn', opts) -- go to next tab +vim.keymap.set('n', 'tp', ':tabp', opts) -- go to previous tab + +-- Toggle line wrapping +vim.keymap.set('n', 'lw', 'set wrap!', opts) + +-- Press jk fast to exit insert mode +vim.keymap.set('i', 'jk', '', opts) +vim.keymap.set('i', 'kj', '', opts) + +-- Stay in indent mode +vim.keymap.set('v', '<', '', '>gv', opts) + +-- Move text up and down +vim.keymap.set('v', '', ':m .+1==', opts) +vim.keymap.set('v', '', ':m .-2==', opts) + +-- Keep last yanked when pasting +vim.keymap.set('v', 'p', '"_dP', opts) + +-- Replace word under cursor +vim.keymap.set('n', 'j', '*``cgn', opts) + +-- Explicitly yank to system clipboard (highlighted and entire row) +vim.keymap.set({ 'n', 'v' }, 'y', [["+y]]) +vim.keymap.set('n', 'Y', [["+Y]]) + +-- Toggle diagnostics +local diagnostics_active = true + +vim.keymap.set('n', 'do', function() + diagnostics_active = not diagnostics_active + + if diagnostics_active then + vim.diagnostic.enable(0) + else + vim.diagnostic.disable(0) + end +end) + +-- 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', 'd', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + +-- Save and load session +vim.keymap.set('n', 'ss', ':mksession! .session.vim', { noremap = true, silent = false }) +vim.keymap.set('n', 'sl', ':source .session.vim', { noremap = true, silent = false }) + +-- exit insrrt mode with jk +vim.keymap.set('i', 'jk', '', { noremap = true, silent = true, desc = '' }) +-- -- option + a to select all text in a file +vim.keymap.set('n', '', 'ggVG', { noremap = true, silent = true, desc = 'Select all' }) +-- +-- Map the function to a key combination +vim.keymap.set('n', 'te', 'oif err != nil {}Oreturn err') +-- +-- -- Remap x to close the current buffer +vim.api.nvim_set_keymap('n', 'x', ':bd', { noremap = true, silent = true }) + +-- vim.api.nvim_del_keymap('n', 'l') + +-- Function to restart LSP +vim.api.nvim_set_keymap('n', 'L', ':LspRestart', { noremap = true, silent = true }) + +-- -- Remap l to restart LSP +vim.api.nvim_set_keymap('n', 'l', 'lua restart_lsp()', { noremap = true, silent = true }) + +-- Remap leader+f to leader+F +vim.api.nvim_set_keymap('n', '', 'fF', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ff', 'fF', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ft', 'fT', { noremap = true, silent = true }) + +vim.keymap.set('n', '', '20j', { noremap = true, silent = true }) +vim.keymap.set('n', '', '20k', { noremap = true, silent = true }) + +-- diagnostic +local diagnostic_goto = function(next, severity) + local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev + severity = severity and vim.diagnostic.severity[severity] or nil + return function() + go { severity = severity } + end +end +vim.keymap.set('n', 'cd', vim.diagnostic.open_float, { desc = 'Line Diagnostics' }) +vim.keymap.set('n', ']d', diagnostic_goto(true), { desc = 'Next Diagnostic' }) +vim.keymap.set('n', '[d', diagnostic_goto(false), { desc = 'Prev Diagnostic' }) +vim.keymap.set('n', ']e', diagnostic_goto(true, 'ERROR'), { desc = 'Next Error' }) +vim.keymap.set('n', '[e', diagnostic_goto(false, 'ERROR'), { desc = 'Prev Error' }) +vim.keymap.set('n', ']w', diagnostic_goto(true, 'WARN'), { desc = 'Next Warning' }) +vim.keymap.set('n', '[w', diagnostic_goto(false, 'WARN'), { desc = 'Prev Warning' }) + +vim.api.nvim_set_hl(0, '@lsp.type.unused', { link = 'Comment' }) + +-- jumping lines +-- vim.keymap.del("n", "") +-- vim.keymap.del("n", "") +vim.keymap.set("n", "", "{", { noremap = true, silent = true }) -- Jump up to previous empty line +vim.keymap.set("n", "", "}", { noremap = true, silent = true }) -- Jump down to next empty line + + + +vim.keymap.set('n', 'st', function() + require('telescope.builtin').live_grep({ default_text = "// TODO:" }) +end, { desc = "Search for TODO comments" }) + +vim.keymap.set('n', 'sx', function() + require('telescope.builtin').live_grep({ default_text = "// FUTURE:" }) +end, { desc = "Search for FUTURE comments" }) + +vim.keymap.set('n', 'si', function() + require('telescope.builtin').live_grep({ default_text = "// IMPORTANT:" }) +end, { desc = "Search for IMPORTANT comments" }) + +-- Define highlight groups for comment tags +vim.api.nvim_set_hl(0, "FutureHighlight", { bg = "#3b4252", fg = "#81a1c1", bold = true }) -- Light blue +vim.api.nvim_set_hl(0, "FixmeHighlight", { bg = "#3b4252", fg = "#bf616a", bold = true }) -- Red +vim.api.nvim_set_hl(0, "NoteHighlight", { bg = "#3b4252", fg = "#ebcb8b", bold = true }) -- Yellow +vim.api.nvim_set_hl(0, "QuestionHighlight", { bg = "#3b4252", fg = "#b48ead", bold = true }) -- Purple +vim.api.nvim_set_hl(0, "ImportantHighlight", { bg = "#3b4252", fg = "#a3be8c", bold = true }) -- Green + diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 00000000..07e6380a --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,63 @@ +vim.o.hlsearch = false -- Set highlight on search +vim.wo.number = true -- Make line numbers default +vim.o.mouse = 'a' -- Enable mouse mode +vim.o.clipboard = 'unnamedplus' -- Sync clipboard between OS and Neovim. +vim.o.breakindent = true -- Enable break indent +vim.o.undofile = true -- Save undo history +vim.o.ignorecase = true -- Case-insensitive searching UNLESS \C or capital in search +vim.o.smartcase = true -- smart case +vim.wo.signcolumn = 'yes' -- Keep signcolumn on by default +vim.o.updatetime = 250 -- Decrease update time +vim.o.timeoutlen = 300 -- time to wait for a mapped sequence to complete (in milliseconds) +vim.o.backup = false -- creates a backup file +vim.o.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited +vim.o.completeopt = 'menuone,noselect' -- Set completeopt to have a better completion experience +vim.opt.termguicolors = true -- set termguicolors to enable highlight groups +vim.o.whichwrap = 'bs<>[]hl' -- which "horizontal" keys are allowed to travel to prev/next line +vim.o.wrap = false -- display lines as one long line +vim.o.linebreak = true -- companion to wrap don't split words +vim.o.scrolloff = 0 -- minimal number of screen lines to keep above and below the cursor +vim.o.sidescrolloff = 8 -- minimal number of screen columns either side of cursor if wrap is `false` +vim.o.relativenumber = true -- set relative numbered lines +vim.o.numberwidth = 4 -- set number column width to 2 {default 4} +vim.o.shiftwidth = 4 -- the number of spaces inserted for each indentation +vim.o.tabstop = 2 -- insert n spaces for a tab +vim.o.softtabstop = 4 -- Number of spaces that a tab counts for while performing editing operations +vim.o.expandtab = true -- convert tabs to spaces +vim.o.cursorline = true -- highlight the current line +vim.o.splitbelow = true -- force all horizontal splits to go below current window +vim.o.splitright = true -- force all vertical splits to go to the right of current window +vim.o.swapfile = false -- creates a swapfile +vim.o.smartindent = true -- make indenting smarter again +vim.o.showmode = false -- we don't need to see things like -- INSERT -- anymore +vim.o.showtabline = 2 -- always show tabs +vim.o.backspace = 'indent,eol,start' -- allow backspace on +vim.o.pumheight = 10 -- pop up menu height +vim.o.conceallevel = 0 -- so that `` is visible in markdown files +vim.o.fileencoding = 'utf-8' -- the encoding written to a file +vim.o.cmdheight = 1 -- more space in the neovim command line for displaying messages +vim.o.autoindent = true -- copy indent from current line when starting new one +vim.opt.shortmess:append 'c' -- don't give |ins-completion-menu| messages +vim.opt.iskeyword:append '-' -- hyphenated words recognized by searches +vim.opt.formatoptions:remove { 'c', 'r', 'o' } -- don't insert the current comment leader automatically for auto-wrapping comments using 'textwidth', hitting in insert mode, or hitting 'o' or 'O' in normal mode. +vim.opt.runtimepath:remove '/usr/share/vim/vimfiles' -- separate vim plugins from neovim in case vim still in use + + +-- -- Ensure fold method is set (syntax-based folding is great for Nim) +-- vim.o.foldmethod = "syntax" +-- vim.o.foldenable = true -- Enable folding at startup +-- vim.o.foldlevel = 99 -- Open all folds by default + + + +-- Use Treesitter for better folding (Recommended) +vim.opt.foldmethod = "expr" +vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + +-- Set fold level +vim.opt.foldenable = true +vim.opt.foldlevel = 99 -- Keep folds open by default + + + + diff --git a/lua/core/snippets.lua b/lua/core/snippets.lua new file mode 100644 index 00000000..5c17d970 --- /dev/null +++ b/lua/core/snippets.lua @@ -0,0 +1,45 @@ +-- Custom code snippets for different purposes + +-- Prevent LSP from overwriting treesitter color settings +-- https://github.com/NvChad/NvChad/issues/1907 +vim.highlight.priorities.semantic_tokens = 95 -- Or any number lower than 100, treesitter's priority level + +-- Appearance of diagnostics +vim.diagnostic.config { + virtual_text = { + prefix = '●', + -- Add a custom format function to show error codes + format = function(diagnostic) + local code = diagnostic.code and string.format('[%s]', diagnostic.code) or '' + return string.format('%s %s', code, diagnostic.message) + end, + }, + underline = false, + update_in_insert = true, + float = { + source = 'always', -- Or "if_many" + }, + -- Make diagnostic background transparent + on_ready = function() + vim.cmd 'highlight DiagnosticVirtualText guibg=NONE' + end, +} + +-- Highlight on yank +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', +}) + +-- Set kitty terminal padding to 0 when in nvim +vim.cmd [[ + augroup kitty_mp + autocmd! + au VimLeave * :silent !kitty @ set-spacing padding=default margin=default + au VimEnter * :silent !kitty @ set-spacing padding=0 margin=0 3 0 3 + augroup END +]] diff --git a/lua/core/ui.lua b/lua/core/ui.lua new file mode 100644 index 00000000..d2a1d197 --- /dev/null +++ b/lua/core/ui.lua @@ -0,0 +1,59 @@ +return { + { + 'folke/noice.nvim', + opts = function(_, opts) + -- 🔥 Ensure `opts.presets` is initialized before modifying + opts.presets = opts.presets or {} + opts.presets.lsp_doc_border = true + + -- 🔥 Ensure `opts.routes` is a table before inserting + opts.routes = opts.routes or {} + table.insert(opts.routes, { + filter = { + event = 'notify', + find = 'No information available', + }, + opts = { skip = true }, + }) + end, + }, + { + 'akinsho/bufferline.nvim', + event = 'VeryLazy', + opts = { + options = { + show_buffer_close_icons = false, + show_close_icon = false, + }, + }, + }, + { + 'nvimdev/dashboard-nvim', + event = 'VimEnter', + opts = function(_, opts) + local logo = [[ + + ████████ ████████ + ██ ██ ██ + ▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▒▒▒▒ ████ + ▒▒▒▒ ▒▒▒▒▒▒ + ████████▒▒▒▒▒▒ ▒▒▒▒██▒▒██████ + ████ ▒▒▒▒██▒▒▒▒ ▒▒▒▒████▒▒▒▒ ████ +████ ▒▒▒▒ ████▒▒ ▒▒▒▒████ ▒▒ ████ +██ ▒▒ ██▒▒ ▒▒▒▒ ██ ▒▒ ██ +██ ▒▒▒▒▒▒▒▒▒▒▒▒██▒▒ ██ ▒▒ ██ +██ ██ ██ ██ ██ +████ ████ ██ ████ ████ + ████ ████ ████ ████ + ██████████ ██████████ + + ]] + + logo = string.rep('\n', 8) .. logo .. '\n\n' + + -- 🔥 Ensure `opts.config` is a table before modifying + opts.config = opts.config or {} + opts.config.header = vim.split(logo, '\n') + end, + }, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100644 index be0eb9d8..00000000 --- a/lua/custom/plugins/init.lua +++ /dev/null @@ -1,5 +0,0 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) --- --- See the kickstart.nvim README for more information -return {} diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua deleted file mode 100644 index b59d0864..00000000 --- a/lua/kickstart/health.lua +++ /dev/null @@ -1,52 +0,0 @@ ---[[ --- --- 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 deleted file mode 100644 index 87a7e5ff..00000000 --- a/lua/kickstart/plugins/autopairs.lua +++ /dev/null @@ -1,16 +0,0 @@ --- 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 deleted file mode 100644 index 753cb0ce..00000000 --- a/lua/kickstart/plugins/debug.lua +++ /dev/null @@ -1,148 +0,0 @@ --- 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 deleted file mode 100644 index c269bc06..00000000 --- a/lua/kickstart/plugins/gitsigns.lua +++ /dev/null @@ -1,61 +0,0 @@ --- Adds git related signs to the gutter, as well as utilities for managing changes --- NOTE: gitsigns is already included in init.lua but contains only the base --- config. This will add also the recommended keymaps. - -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 deleted file mode 100644 index ed7f2693..00000000 --- a/lua/kickstart/plugins/indent_line.lua +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100644 index 907c6bf3..00000000 --- a/lua/kickstart/plugins/lint.lua +++ /dev/null @@ -1,60 +0,0 @@ -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 deleted file mode 100644 index bd442269..00000000 --- a/lua/kickstart/plugins/neo-tree.lua +++ /dev/null @@ -1,25 +0,0 @@ --- 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/plugins/aerial.lua b/lua/plugins/aerial.lua new file mode 100644 index 00000000..bdda1f3f --- /dev/null +++ b/lua/plugins/aerial.lua @@ -0,0 +1,26 @@ +return { + 'stevearc/aerial.nvim', + lazy_load = true, + opts = {}, + -- Optional dependencies + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'nvim-tree/nvim-web-devicons', + }, + config = function() + require('aerial').setup { + -- optionally use on_attach to set keymaps when aerial has attached to a buffer + on_attach = function(bufnr) + -- Jump forwards/backwards with '{' and '}' + -- vim.keymap.set('n', '{', 'AerialPrev', { buffer = bufnr }) + -- vim.keymap.set('n', '}', 'AerialNext', { buffer = bufnr }) + end, + layout = { + min_width = 30, + }, + } + -- You probably also want to set a keymap to toggle aerial + vim.keymap.set('n', 'o', 'AerialToggle!') + vim.keymap.set('n', 'on', 'AerialNavToggle') + end, +} diff --git a/lua/plugins/autocompletion.lua b/lua/plugins/autocompletion.lua new file mode 100644 index 00000000..20b99ae7 --- /dev/null +++ b/lua/plugins/autocompletion.lua @@ -0,0 +1,143 @@ +return { -- 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)(), + }, + '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-buffer', + 'hrsh7th/cmp-path', + + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, + config = function() + local cmp = require 'cmp' + require('luasnip.loaders.from_vscode').lazy_load() + local luasnip = require 'luasnip' + luasnip.config.setup {} + + local kind_icons = { + Text = '󰉿', + Method = 'm', + Function = '󰊕', + Constructor = '', + Field = '', + Variable = '󰆧', + Class = '󰌗', + Interface = '', + Module = '', + Property = '', + Unit = '', + Value = '󰎠', + Enum = '', + Keyword = '󰌋', + Snippet = '', + Color = '󰏘', + File = '󰈙', + Reference = '', + Folder = '󰉋', + EnumMember = '', + Constant = '󰇽', + Struct = '', + Event = '', + Operator = '󰆕', + TypeParameter = '󰊄', + } + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = 'menu,menuone,noinsert' }, + -- window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + -- }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), -- Select the [n]ext item + [''] = cmp.mapping.select_prev_item(), -- Select the [p]revious item + [''] = cmp.mapping.confirm { select = true }, -- Accept the completion with Enter. + [''] = cmp.mapping.complete {}, -- Manually trigger a completion from nvim-cmp. + + -- 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' }), + + -- Select next/previous item with Tab / Shift + Tab + [''] = 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' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'path' }, + }, + formatting = { + fields = { 'kind', 'abbr', 'menu' }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format('%s', kind_icons[vim_item.kind]) + -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + vim_item.menu = ({ + nvim_lsp = '[LSP]', + luasnip = '[Snippet]', + buffer = '[Buffer]', + path = '[Path]', + })[entry.source.name] + return vim_item + end, + }, + } + end, +} diff --git a/lua/plugins/avante.lua b/lua/plugins/avante.lua new file mode 100644 index 00000000..765c3314 --- /dev/null +++ b/lua/plugins/avante.lua @@ -0,0 +1,28 @@ +return { + 'yetone/avante.nvim', + event = 'VeryLazy', + build = 'make', + opts = { + provider = 'claude', + claude = { + endpoint = os.getenv 'AVANTE_ANTHROPIC_ENDPOINT' or 'https://api.anthropic.com', + model = 'claude-3-5-sonnet-20240620', + timeout = 30000, -- Timeout in milliseconds + temperature = 0, + max_tokens = 4096, + }, + openai = { + endpoint = os.getenv 'AVANTE_OPENAI_ENDPOINT' or 'https://api.openai.com/v1', + model = 'gpt-4o', + timeout = 30000, -- Timeout in milliseconds + temperature = 0, + max_tokens = 4096, + }, + }, + dependencies = { + 'nvim-tree/nvim-web-devicons', + 'stevearc/dressing.nvim', + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + }, +} diff --git a/lua/plugins/better-comments.lua b/lua/plugins/better-comments.lua new file mode 100644 index 00000000..c2fb3276 --- /dev/null +++ b/lua/plugins/better-comments.lua @@ -0,0 +1,140 @@ + +-- TODO: don't having to resave to remove extmark +-- TODO: see the others TODO + + +local M = {} + +local api = vim.api +local cmd = vim.api.nvim_create_autocmd +local treesitter = vim.treesitter +local opts = { + tags = { + { + name = "TODO", + fg = "white", + bg = "#0a7aca", + bold = true, + }, + { + name = "FIX", + fg = "white", + bg = "#f44747", + bold = true, + }, + { + name = "WARNING", + fg = "#FFA500", + bold = false, + }, + { + name = "FUTURE", + fg = "#f44747", + bold = true, + } + + }, +} + + +M.Setup = function(config) + if config and config.default==false then + opts.tags = {} + end + if config and config.tags then + opts.tags = vim.tbl_deep_extend("force", opts.tags, config.tags or {}) + end + + local augroup = vim.api.nvim_create_augroup("better-comments", {clear = true}) + cmd({ 'BufWinEnter', 'BufFilePost', 'BufWritePost', 'TextChanged', 'TextChangedI' }, { + group = augroup, + callback = function() + local current_buffer = api.nvim_get_current_buf() + local current_buffer_name = api.nvim_buf_get_name(current_buffer) + if current_buffer_name == '' then + return + end + local fileType = api.nvim_buf_get_option(current_buffer, "filetype") + local success, parsed_query = pcall(function() + return treesitter.query.parse(fileType, [[(comment) @all]]) + end) + if not success then + return + end + local commentsTree = treesitter.query.parse(fileType, [[(comment) @all]]) + + -- FIX: Check if file has treesitter + local root = Get_root(current_buffer, fileType) + local comments = {} + for _, node in commentsTree:iter_captures(root, current_buffer, 0, -1) do + local range = { node:range() } + table.insert(comments, { + line = range[1], + col_start = range[2], + finish = range[4], + text = vim.treesitter.get_node_text(node, current_buffer) + }) + end + + if comments == {} then + return + end + Create_hl(opts.tags) + + for id, comment in ipairs(comments) do + for hl_id, hl in ipairs(opts.tags) do + if string.find(comment.text, hl.name) then + local ns_id = vim.api.nvim_create_namespace(hl.name) + if hl.virtual_text and hl.virtual_text ~= "" then + local v_opts = { + id = id, + virt_text = { { hl.virtual_text, "" } }, + virt_text_pos = 'overlay', + virt_text_win_col = comment.finish + 2, + } + + -- FIX: comment.line -> 0 in col + api.nvim_buf_set_extmark(current_buffer, ns_id, comment.line, 0, v_opts) + end + + -- FIX: using for ns_id ns_id instead of 0 + -- so that when we clear the namespace the color also clear + vim.api.nvim_buf_add_highlight(current_buffer, ns_id, tostring(hl_id), comment.line, + comment.col_start, + comment.finish) + else + -- FIX: added else to delted extmark + + -- TODO: THIS PART IS CALLED A LOT FIND A WAY TO NOT CHECK EVERY TIME + if hl.virtual_text ~= "" then + local ns_id = vim.api.nvim_create_namespace(hl.name) + + -- FIX: clearing the namespace to delete the extmark and the color + api.nvim_buf_clear_namespace(current_buffer, ns_id, comment.line, comment.line+1) + end + end + end + end + end + }) +end + +Get_root = function(bufnr, filetype) + local parser = vim.treesitter.get_parser(bufnr, filetype, {}) + local tree = parser:parse()[1] + return tree:root() +end + +function Create_hl(list) + for id, hl in ipairs(list) do + vim.api.nvim_set_hl(0, tostring(id), { + fg = hl.fg, + bg = hl.bg, + bold = hl.bold, + underline = hl.underline, + }) + end +end + +return M + diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua new file mode 100644 index 00000000..968096de --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,81 @@ +return { + 'akinsho/bufferline.nvim', + dependencies = { + 'moll/vim-bbye', + 'nvim-tree/nvim-web-devicons', + }, + config = function() + -- vim.opt.linespace = 8 + + require('bufferline').setup { + options = { + mode = 'buffers', -- set to "tabs" to only show tabpages instead + themable = true, -- allows highlight groups to be overriden i.e. sets highlights as default + numbers = 'none', -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, + close_command = 'Bdelete! %d', -- can be a string | function, see "Mouse actions" + right_mouse_command = 'Bdelete! %d', -- can be a string | function, see "Mouse actions" + left_mouse_command = 'buffer %d', -- can be a string | function, see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" + -- buffer_close_icon = '󰅖', + buffer_close_icon = '✗', + -- buffer_close_icon = '✕', + close_icon = '', + path_components = 1, -- Show only the file name without the directory + modified_icon = '●', + left_trunc_marker = '', + right_trunc_marker = '', + max_name_length = 30, + max_prefix_length = 30, -- prefix used when a buffer is de-duplicated + tab_size = 21, + diagnostics = false, + diagnostics_update_in_insert = false, + color_icons = true, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + separator_style = { '│', '│' }, -- | "thick" | "thin" | { 'any', 'any' }, + enforce_regular_tabs = true, + always_show_bufferline = true, + show_tab_indicators = false, + indicator = { + -- icon = '▎', -- this should be omitted if indicator style is not 'icon' + style = 'none', -- Options: 'icon', 'underline', 'none' + }, + icon_pinned = '󰐃', + minimum_padding = 1, + maximum_padding = 5, + maximum_length = 15, + sort_by = 'insert_at_end', + }, + highlights = { + separator = { + fg = '#434C5E', + }, + buffer_selected = { + bold = true, + italic = false, + }, + -- separator_selected = {}, + -- tab_selected = {}, + -- background = {}, + -- indicator_selected = {}, + -- fill = {}, + }, + } + + -- Keymaps + local opts = { noremap = true, silent = true, desc = 'Go to Buffer' } + -- vim.keymap.set("n", "", "BufferLineCycleNext", {}) + -- vim.keymap.set("n", "", "BufferLineCyclePrev", {}) + -- vim.keymap.set('n', '1', "lua require('bufferline').go_to_buffer(1)", opts) + -- vim.keymap.set('n', '2', "lua require('bufferline').go_to_buffer(2)", opts) + -- vim.keymap.set('n', '3', "lua require('bufferline').go_to_buffer(3)", opts) + -- vim.keymap.set('n', '4', "lua require('bufferline').go_to_buffer(4)", opts) + -- vim.keymap.set('n', '5', "lua require('bufferline').go_to_buffer(5)", opts) + -- vim.keymap.set('n', '6', "lua require('bufferline').go_to_buffer(6)", opts) + -- vim.keymap.set('n', '7', "lua require('bufferline').go_to_buffer(7)", opts) + -- vim.keymap.set('n', '8', "lua require('bufferline').go_to_buffer(8)", opts) + -- vim.keymap.set('n', '9', "lua require('bufferline').go_to_buffer(9)", opts) + end, +} diff --git a/lua/plugins/chatgpt.lua b/lua/plugins/chatgpt.lua new file mode 100644 index 00000000..39363cb8 --- /dev/null +++ b/lua/plugins/chatgpt.lua @@ -0,0 +1,158 @@ +return { + 'jackMort/ChatGPT.nvim', + event = 'VeryLazy', + config = function() + vim.api.nvim_set_hl(0, 'ChatGPTNormalFloat', { bg = 'NONE', fg = 'NONE' }) + vim.api.nvim_set_hl(0, 'ChatGPTFloatBorder', { bg = 'NONE', fg = 'NONE' }) + require('chatgpt').setup { + api_key_cmd = nil, + yank_register = '+', + edit_with_instructions = { + diff = false, + keymaps = { + close = '', + accept = '', + toggle_diff = '', + toggle_settings = '', + cycle_windows = '', + use_output_as_input = '', + }, + }, + chat = { + loading_text = 'Loading, please wait ...', + question_sign = '', -- 🙂 + -- answer_sign = 'ﮧ', -- 🤖 + answer_sign = '🤖', + max_line_length = 120, + sessions_window = { + border = { + style = 'rounded', + text = { + top = ' Sessions ', + }, + }, + win_options = { + winhighlight = 'Normal:ChatGPTNormalFloat,FloatBorder:ChatGPTFloatBorder', + }, + }, + }, + keymaps = { + close = { '' }, + yank_last = '', + yank_last_code = '', + scroll_up = '', + scroll_down = '', + new_session = '', + cycle_windows = '', + cycle_modes = '', + next_message = '', + prev_message = '', + select_session = '', + rename_session = 'r', + delete_session = 'd', + draft_message = '', + edit_message = 'e', + delete_message = 'd', + toggle_settings = '', + toggle_message_role = '', + toggle_system_role_open = '', + stop_generating = '', + }, + popup_layout = { + default = 'center', + center = { + width = '60%', + height = '80%', + }, + right = { + width = '30%', + width_settings_open = '50%', + }, + }, + popup_window = { + border = { + highlight = 'Normal:ChatGPTNormalFloat,FloatBorder:ChatGPTFloatBorder', + style = 'rounded', + text = { + top = ' ChatGPT ', + }, + }, + win_options = { + wrap = true, + linebreak = true, + foldcolumn = '1', + winhighlight = 'Normal:ChatGPTNormalFloat,FloatBorder:ChatGPTFloatBorder', + }, + buf_options = { + filetype = 'markdown', + }, + }, + system_window = { + border = { + highlight = 'Normal:ChatGPTNormalFloat,FloatBorder:ChatGPTFloatBorder', + style = 'rounded', + text = { + top = ' SYSTEM ', + }, + }, + win_options = { + wrap = true, + linebreak = true, + foldcolumn = '2', + winhighlight = 'Normal:ChatGPTNormalFloat,FloatBorder:ChatGPTFloatBorder', + }, + }, + popup_input = { + prompt = '  ', + border = { + highlight = 'Normal:ChatGPTNormalFloat,FloatBorder:ChatGPTFloatBorder', + style = 'rounded', + text = { + top_align = 'center', + top = ' Prompt ', + }, + }, + win_options = { + winhighlight = 'Normal:ChatGPTNormalFloat,FloatBorder:ChatGPTFloatBorder', + }, + submit = '', + submit_n = '', + max_visible_lines = 20, + }, + settings_window = { + border = { + style = 'rounded', + text = { + top = ' Settings ', + }, + }, + win_options = { + winhighlight = 'Normal:ChatGPTNormalFloat,FloatBorder:ChatGPTFloatBorder', + }, + }, + -- this config assumes you have OPENAI_API_KEY environment variable set + openai_params = { + model = 'gpt-4o-mini', + frequency_penalty = 0, + presence_penalty = 0, + max_tokens = 4095, + temperature = 0.2, + top_p = 0.1, + n = 1, + }, + openai_edit_params = { + model = 'gpt-3.5-turbo', + frequency_penalty = 0, + presence_penalty = 0, + temperature = 0, + top_p = 1, + n = 1, + }, + } + end, + dependencies = { + 'MunifTanjim/nui.nvim', + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope.nvim', + }, +} diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 00000000..a0b5662c --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,67 @@ +return { + { + "folke/ts-comments.nvim", + opts = { + lang = { + astro = "", + axaml = "", + blueprint = "// %s", + c = "// %s", + c_sharp = "// %s", + clojure = { ";; %s", "; %s" }, + cpp = "// %s", + cs_project = "", + css = "/* %s */", + cue = "// %s", + fsharp = "// %s", + fsharp_project = "", + gleam = "// %s", + glimmer = "{{! %s }}", + handlebars = "{{! %s }}", + hcl = "# %s", + html = "", + ini = "; %s", + javascript = { + "// %s", -- default commentstring when no treesitter node matches + "/* %s */", + call_expression = "// %s", -- specific commentstring for call_expression + jsx_attribute = "// %s", + jsx_element = "{/* %s */}", + jsx_fragment = "{/* %s */}", + spread_element = "// %s", + statement_block = "// %s", + }, + kdl = "// %s", + lua = { "-- %s", "--- %s" }, -- langs can have multiple commentstrings + ocaml = "(* %s *)", + php = "// %s", + rego = "# %s", + rescript = "// %s", + rust = { "// %s", "/* %s */", "/// %s" }, + sql = "-- %s", + svelte = "", + templ = "// %s", + terraform = "# %s", + tsx = { + "// %s", -- default commentstring when no treesitter node matches + "/* %s */", + call_expression = "// %s", -- specific commentstring for call_expression + jsx_attribute = "// %s", + jsx_element = "{/* %s */}", + jsx_fragment = "{/* %s */}", + spread_element = "// %s", + statement_block = "// %s", + }, + twig = "{# %s #}", + typescript = "// %s", + vim = '" %s', + vue = "", + xaml = "", + xml = "", + }, + }, + event = "VeryLazy", + enabled = vim.fn.has("nvim-0.10.0") == 1, + }, + +} diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua new file mode 100644 index 00000000..25327e3a --- /dev/null +++ b/lua/plugins/conform.lua @@ -0,0 +1,17 @@ +return { + { + "stevearc/conform.nvim", + config = function() + require("conform").setup({ + formatters_by_ft = { + templ = { "templ", "prettier" }, -- Use templ first, then Prettier for embedded content + }, + format_on_save = { + timeout_ms = 500, + lsp_fallback = true, + }, + }) + end, + event = { "BufReadPre", "BufNewFile" }, -- Load only when opening a file + } +} diff --git a/lua/plugins/database.lua b/lua/plugins/database.lua new file mode 100644 index 00000000..e80f3fe1 --- /dev/null +++ b/lua/plugins/database.lua @@ -0,0 +1,50 @@ +return { + --use nvim in browser + { 'kristijanhusak/vim-dadbod-ui' }, + { 'kristijanhusak/vim-dadbod-completion' }, + -- Database + { + 'tpope/vim-dadbod', + -- lazy = true, + dependencies = { + 'kristijanhusak/vim-dadbod-ui', + 'kristijanhusak/vim-dadbod-completion', + }, + -- event = 'VeryLazy', + config = function() + vim.g.db_ui_execute_on_save = 0 --do not execute on save + vim.g.db_ui_win_position = 'left' + vim.g.db_ui_use_nerd_fonts = 1 + vim.g.db_ui_icons = { + expanded = { + db = '▼', + buffers = '▼', + saved_queries = '▼', + schemas = '▼', + schema = '▼', + tables = '▼', + table = '▼', + }, + collapsed = { + db = '▶', + buffers = '▶', + saved_queries = '▶', + schemas = '▶', + schema = '▶', + tables = '▶', + table = '▶', + }, + saved_query = '*', + new_query = '+', + tables = '~', + buffers = '»', + add_connection = '[+]', + connection_ok = '✓', + connection_error = '✕', + } + end, + }, +} + +-- {'add_connection': '[+]', 'expanded': {'schemas': '▾', 'saved_queries': '▾', 'db': '▾', 'schema': '▾', 'table': '▾', 'buffers': '▾', 'tables': '▾'}, 'connection_ok': '✓', 'connection_error': '✕', 'tables': '~', ' +-- collapsed': {'schemas': '▸', 'saved_queries': '▸', 'db': '▸', 'schema': '▸', 'table': '▸', 'buffers': '▸', 'tables': '▸'}, 'saved_query': '*', 'buffers': '»', 'new_query': '+'} diff --git a/lua/plugins/debug.lua b/lua/plugins/debug.lua new file mode 100644 index 00000000..3e36acd1 --- /dev/null +++ b/lua/plugins/debug.lua @@ -0,0 +1,82 @@ +return { + 'mfussenegger/nvim-dap', + dependencies = { + -- Creates a beautiful debugger UI + 'rcarriga/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', + 'mfussenegger/nvim-dap-python', + }, + 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_setup = true, + 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', + 'debugpy', + }, + } + + -- Basic debugging keymaps, feel free to change to your liking! + vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) + vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) + vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) + vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) + vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) + vim.keymap.set('n', 'B', function() + dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, { desc = 'Debug: Set Breakpoint' }) + + -- 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 = '⏏', + }, + }, + } + + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) + + 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() + require('dap-python').setup() + end, +} diff --git a/lua/plugins/flash.lua b/lua/plugins/flash.lua new file mode 100644 index 00000000..026c1052 --- /dev/null +++ b/lua/plugins/flash.lua @@ -0,0 +1,16 @@ +return { + { + "folke/flash.nvim", + event = "VeryLazy", + ---@type Flash.Config + opts = {}, + -- stylua: ignore + keys = { + { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, + { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, + { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, + { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, + { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, + }, + } +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 00000000..6870109a --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,21 @@ +-- Adds git related signs to the gutter, as well as utilities for managing changes +return { + 'lewis6991/gitsigns.nvim', + opts = { + -- See `:help gitsigns.txt` + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + signs_staged = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + }, +} diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua new file mode 100644 index 00000000..2f73a4e2 --- /dev/null +++ b/lua/plugins/harpoon.lua @@ -0,0 +1,43 @@ +return { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local harpoon = require 'harpoon' + harpoon:setup {} + + -- Default UI + vim.keymap.set('n', 'H', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end) + + vim.keymap.set('n', 'h', function() + harpoon:list():add() + end) + + vim.keymap.set('n', '1', function() + harpoon:list():select(1) + end) + + vim.keymap.set('n', '2', function() + harpoon:list():select(2) + end) + + vim.keymap.set('n', '3', function() + harpoon:list():select(3) + end) + + vim.keymap.set('n', '4', function() + harpoon:list():select(4) + end) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set('n', 'p', function() + harpoon:list():prev() + end) + + vim.keymap.set('n', 'n', function() + harpoon:list():next() + end) + end, +} diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua new file mode 100644 index 00000000..27e44089 --- /dev/null +++ b/lua/plugins/indent-blankline.lua @@ -0,0 +1,25 @@ +return { + 'lukas-reineke/indent-blankline.nvim', + main = 'ibl', + opts = { + indent = { + char = '▏', + }, + scope = { + show_start = false, + show_end = false, + show_exact_scope = false, + }, + exclude = { + filetypes = { + 'help', + 'startify', + 'dashboard', + 'packer', + 'neogitstatus', + 'NvimTree', + 'Trouble', + }, + }, + }, +} diff --git a/lua/plugins/lazygit.lua b/lua/plugins/lazygit.lua new file mode 100644 index 00000000..a6226341 --- /dev/null +++ b/lua/plugins/lazygit.lua @@ -0,0 +1,29 @@ +return { + 'kdheepak/lazygit.nvim', + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + -- optional for floating window border decoration + dependencies = { + 'nvim-lua/plenary.nvim', + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + -- Run LazyGit command and set background to transparent + { 'gg', 'LazyGithi LazyGitFloat guibg=NONE guifg=NONEsetlocal winhl=NormalFloat:LazyGitFloat', desc = 'LazyGit' }, + }, + config = function() + vim.g.lazygit_floating_window_winblend = 0 -- transparency of floating window (0-100) + vim.g.lazygit_floating_window_scaling_factor = 0.9 -- scaling factor for floating window + vim.g.lazygit_floating_window_border_chars = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' } -- customize lazygit popup window border characters + vim.g.lazygit_floating_window_use_plenary = 0 -- use plenary.nvim to manage floating window if available + vim.g.lazygit_use_neovim_remote = 1 -- fallback to 0 if neovim-remote is not installed + vim.g.lazygit_use_custom_config_file_path = 0 -- config file path is evaluated if this value is 1 + vim.g.lazygit_config_file_path = {} -- table of custom config file paths + end, +} diff --git a/lua/plugins/lsp-keymaps.lua b/lua/plugins/lsp-keymaps.lua new file mode 100644 index 00000000..f58321fa --- /dev/null +++ b/lua/plugins/lsp-keymaps.lua @@ -0,0 +1,209 @@ +local M = {} + +M._keys = nil + +---@return table +function M.get() + if M._keys then + return M._keys + end + + -- Standard LSP Keybindings (No LazyVim) + M._keys = { + { 'cl', 'LspInfo', desc = 'LSP Info' }, + { 'gd', vim.lsp.buf.definition, desc = 'Go to Definition' }, + { 'gr', vim.lsp.buf.references, desc = 'References' }, + { 'gI', vim.lsp.buf.implementation, desc = 'Go to Implementation' }, + { 'gy', vim.lsp.buf.type_definition, desc = 'Go to Type Definition' }, + { 'gD', vim.lsp.buf.declaration, desc = 'Go to Declaration' }, + { 'K', vim.lsp.buf.hover, desc = 'Hover' }, + { 'gK', vim.lsp.buf.signature_help, desc = 'Signature Help' }, + { '', vim.lsp.buf.signature_help, mode = 'i', desc = 'Signature Help' }, + { 'ca', vim.lsp.buf.code_action, desc = 'Code Action', mode = { 'n', 'v' } }, + { 'cr', vim.lsp.buf.rename, desc = 'Rename' }, + { + 'cR', + function() + if require 'snacks.rename' then + require('snacks.rename').rename_file() + else + print 'Snacks rename not available' + end + end, + desc = 'Rename File', + mode = { 'n' }, + has = { 'workspace/didRenameFiles', 'workspace/willRenameFiles' }, + }, + { 'cr', vim.lsp.buf.rename, desc = 'Rename', has = 'rename' }, + } + + return M._keys +end + +---@param buffer number +function M.on_attach(_, buffer) + for _, key in pairs(M.get()) do + vim.keymap.set(key.mode or 'n', key[1], key[2], { buffer = buffer, desc = key.desc, silent = true }) + end +end + +return M +-- local M = {} +-- +-- ---@type LazyKeysLspSpec[]|nil +-- M._keys = nil +-- +-- ---@alias LazyKeysLspSpec LazyKeysSpec|{has?:string|string[], cond?:fun():boolean} +-- ---@alias LazyKeysLsp LazyKeys|{has?:string|string[], cond?:fun():boolean} +-- +-- ---@return LazyKeysLspSpec[] +-- function M.get() +-- if M._keys then +-- return M._keys +-- end +-- -- stylua: ignore +-- M._keys = { +-- { "cl", "LspInfo", desc = "LSP Info" }, +-- { "gd", vim.lsp.buf.definition, desc = "Go to Definition", has = "definition" }, +-- { "gr", vim.lsp.buf.references, desc = "References", nowait = true }, +-- { "gI", vim.lsp.buf.implementation, desc = "Go to Implementation" }, +-- { "gy", vim.lsp.buf.type_definition, desc = "Go to Type Definition" }, +-- { "gD", vim.lsp.buf.declaration, desc = "Go to Declaration" }, +-- { "K", function() return vim.lsp.buf.hover() end, desc = "Hover" }, +-- { "gK", function() return vim.lsp.buf.signature_help() end, desc = "Signature Help", has = "signatureHelp" }, +-- { "", function() return vim.lsp.buf.signature_help() end, mode = "i", desc = "Signature Help", has = "signatureHelp" }, +-- { "ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" }, +-- { "cc", vim.lsp.codelens.run, desc = "Run CodeLens", mode = { "n", "v" }, has = "codeLens" }, +-- { "cC", vim.lsp.codelens.refresh, desc = "Refresh & Display CodeLens", mode = { "n" }, has = "codeLens" }, +-- { +-- "cR", +-- function() +-- if require("snacks.rename") then +-- require("snacks.rename").rename_file() +-- else +-- print("Snacks rename not available") +-- end +-- end, +-- desc = "Rename File", +-- mode = { "n" }, +-- has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } +-- }, +-- { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" }, +-- { +-- "cA", +-- function() +-- if require("lazyvim.lsp.action") then +-- require("lazyvim.lsp.action").source() +-- else +-- print("LazyVim LSP action not available") +-- end +-- end, +-- desc = "Source Action", +-- has = "codeAction" +-- }, +-- { +-- "]]", +-- function() +-- if require("snacks.words") then +-- require("snacks.words").jump(vim.v.count1) +-- end +-- end, +-- has = "documentHighlight", +-- desc = "Next Reference", +-- cond = function() return require("snacks.words").is_enabled() end +-- }, +-- { +-- "[[", +-- function() +-- if require("snacks.words") then +-- require("snacks.words").jump(-vim.v.count1) +-- end +-- end, +-- has = "documentHighlight", +-- desc = "Previous Reference", +-- cond = function() return require("snacks.words").is_enabled() end +-- }, +-- { +-- "", +-- function() +-- if require("snacks.words") then +-- require("snacks.words").jump(vim.v.count1, true) +-- end +-- end, +-- has = "documentHighlight", +-- desc = "Next Reference", +-- cond = function() return require("snacks.words").is_enabled() end +-- }, +-- { +-- "", +-- function() +-- if require("snacks.words") then +-- require("snacks.words").jump(-vim.v.count1, true) +-- end +-- end, +-- has = "documentHighlight", +-- desc = "Previous Reference", +-- cond = function() return require("snacks.words").is_enabled() end +-- }, +-- } +-- +-- return M._keys +-- end +-- +-- ---@param buffer number +-- ---@param method string|string[] +-- function M.has(buffer, method) +-- if type(method) == 'table' then +-- for _, m in ipairs(method) do +-- if M.has(buffer, m) then +-- return true +-- end +-- end +-- return false +-- end +-- method = method:find '/' and method or 'textDocument/' .. method +-- local clients = vim.lsp.get_active_clients { bufnr = buffer } +-- for _, client in ipairs(clients) do +-- if client.supports_method(method) then +-- return true +-- end +-- end +-- return false +-- end +-- +-- ---@return LazyKeysLsp[] +-- function M.resolve(buffer) +-- local Keys = require 'lazy.core.handler.keys' +-- if not Keys.resolve then +-- return {} +-- end +-- local spec = vim.tbl_extend('force', {}, M.get()) +-- local opts = require 'nvim-lspconfig' +-- local clients = vim.lsp.get_active_clients { bufnr = buffer } +-- for _, client in ipairs(clients) do +-- local maps = opts.servers and opts.servers[client.name] and opts.servers[client.name].keys or {} +-- vim.list_extend(spec, maps) +-- end +-- return Keys.resolve(spec) +-- end +-- +-- function M.on_attach(_, buffer) +-- local Keys = require 'lazy.core.handler.keys' +-- local keymaps = M.resolve(buffer) +-- +-- for _, keys in pairs(keymaps) do +-- local has = not keys.has or M.has(buffer, keys.has) +-- local cond = not (keys.cond == false or ((type(keys.cond) == 'function') and not keys.cond())) +-- +-- if has and cond then +-- local opts = Keys.opts(keys) +-- opts.cond = nil +-- opts.has = nil +-- opts.silent = opts.silent ~= false +-- opts.buffer = buffer +-- vim.keymap.set(keys.mode or 'n', keys.lhs, keys.rhs, opts) +-- end +-- end +-- end +-- +-- return M diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 00000000..faae141e --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,170 @@ +return { + 'neovim/nvim-lspconfig', + dependencies = { + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + { + 'j-hui/fidget.nvim', + tag = 'v1.4.0', + opts = { + progress = { + display = { done_icon = '✓' }, + }, + notification = { + window = { winblend = 0 }, + }, + }, + }, + { + 'glepnir/lspsaga.nvim', + event = 'LspAttach', + config = function() + require('lspsaga').setup { + ui = { border = 'rounded', title = true }, + hover = { max_width = 0.6 }, + rename = { in_select = false }, + } + end, + }, + }, + + config = function() + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('lsp-attach', { clear = true }), + callback = function(event) + local map = function(keys, func, desc) + vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + local telescope_ok, telescope = pcall(require, 'telescope.builtin') + if not telescope_ok then return end + + map('gd', telescope.lsp_definitions, 'Go to Definition') + map('gr', telescope.lsp_references, 'Go to References') + map('gI', telescope.lsp_implementations, 'Go to Implementation') + map('D', telescope.lsp_type_definitions, 'Type Definition') + map('ds', telescope.lsp_document_symbols, 'Document Symbols') + map('ws', telescope.lsp_dynamic_workspace_symbols, 'Workspace Symbols') + map('rn', vim.lsp.buf.rename, 'Rename') + map('ca', vim.lsp.buf.code_action, 'Code Action') + map('gD', vim.lsp.buf.declaration, 'Go to Declaration') + + map('', function() + local lspsaga_hover_ok, lspsaga_hover = pcall(require, 'lspsaga.hover') + if lspsaga_hover_ok then + lspsaga_hover:render_hover_doc() + else + vim.lsp.buf.hover() + end + end, 'Show Hover') + + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.server_capabilities.documentHighlightProvider then + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + callback = vim.lsp.buf.document_highlight, + }) + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + callback = vim.lsp.buf.clear_references, + }) + end + end, + }) + + -- LSP Server Configurations + local servers = { + gopls = { + settings = { + gopls = { + experimentalPostfixCompletions = true, + gofumpt = true, + staticcheck = true, + analyses = { unusedparams = true }, + directoryFilters = { '-node_modules' }, + templ = { + format = true, + lint = true, + }, + }, + }, + filetypes = { 'go', 'templ' }, + }, + -- tsserver = { settings = { completions = { completeFunctionCalls = true }, }, filetypes = { 'typescript', 'typescriptreact', 'typescript.tsx', 'javascript' }, root_dir = require('lspconfig.util').root_pattern('package.json', 'tsconfig.json', '.git'), }, + eslint = {}, + html = { filetypes = { 'html', 'twig', 'hbs' } }, -- Removed 'templ' from here + templ = { + cmd = { vim.fn.stdpath("data") .. "/mason/bin/templ", "lsp" }, + filetypes = { "templ" }, + root_dir = require("lspconfig").util.root_pattern("go.mod", ".git"), + }, + lua_ls = { + settings = { + Lua = { + runtime = { version = 'LuaJIT' }, + workspace = { + checkThirdParty = false, + library = { + '${3rd}/luv/library', + unpack(vim.api.nvim_get_runtime_file('', true)), + }, + }, + completion = { callSnippet = 'Replace' }, + telemetry = { enable = false }, + diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + dockerls = {}, + docker_compose_language_service = {}, + rust_analyzer = { + ['rust-analyzer'] = { + cargo = { features = 'all' }, + checkOnSave = true, + check = { command = 'clippy' }, + }, + }, + tailwindcss = {}, + jsonls = {}, + yamlls = {}, + bashls = {}, + graphql = {}, + cssls = {}, + } + + -- Enable LSP Features + require('mason').setup() + local ensure_installed = vim.tbl_keys(servers) + vim.list_extend(ensure_installed, { 'templ', 'typescript-language-server' }) + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + require('mason-lspconfig').setup { + handlers = { + function(server_name) + local server = servers[server_name] or {} + server.capabilities = vim.tbl_deep_extend( + 'force', + {}, + vim.lsp.protocol.make_client_capabilities(), + require('cmp_nvim_lsp').default_capabilities(), + server.capabilities or {} + ) + require('lspconfig')[server_name].setup(server) + end, + }, + } + + -- Auto-format and organize imports on save for Go + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + vim.lsp.buf.format({ async = false }) -- Format + vim.lsp.buf.code_action({ + context = { only = { "source.organizeImports" } }, + apply = true, + }) -- Organize imports + end, + }) + end, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 00000000..4053bf56 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,116 @@ +-- Set lualine as statusline +return { + 'nvim-lualine/lualine.nvim', + config = function() + -- Adapted from: https://github.com/nvim-lualine/lualine.nvim/blob/master/lua/lualine/themes/onedark.lua + local colors = { + blue = '#61afef', + green = '#98c379', + purple = '#c678dd', + cyan = '#56b6c2', + red1 = '#e06c75', + red2 = '#be5046', + yellow = '#e5c07b', + fg = '#abb2bf', + bg = '#282c34', + gray1 = '#828997', + gray2 = '#2c323c', + gray3 = '#3e4452', + } + + local onedark_theme = { + normal = { + a = { fg = colors.bg, bg = colors.green, gui = 'bold' }, + b = { fg = colors.fg, bg = colors.gray3 }, + c = { fg = colors.fg, bg = colors.gray2 }, + }, + command = { a = { fg = colors.bg, bg = colors.yellow, gui = 'bold' } }, + insert = { a = { fg = colors.bg, bg = colors.blue, gui = 'bold' } }, + visual = { a = { fg = colors.bg, bg = colors.purple, gui = 'bold' } }, + terminal = { a = { fg = colors.bg, bg = colors.cyan, gui = 'bold' } }, + replace = { a = { fg = colors.bg, bg = colors.red1, gui = 'bold' } }, + inactive = { + a = { fg = colors.gray1, bg = colors.bg, gui = 'bold' }, + b = { fg = colors.gray1, bg = colors.bg }, + c = { fg = colors.gray1, bg = colors.gray2 }, + }, + } + + -- Import color theme based on environment variable NVIM_THEME + local env_var_nvim_theme = os.getenv 'NVIM_THEME' or 'nord' + + -- Define a table of themes + local themes = { + onedark = onedark_theme, + nord = 'nord', + } + + local mode = { + 'mode', + fmt = function(str) + -- return ' ' .. str:sub(1, 1) -- displays only the first character of the mode + return ' ' .. str + end, + } + + local filename = { + 'filename', + file_status = true, -- displays file status (readonly status, modified status) + path = 0, -- 0 = just filename, 1 = relative path, 2 = absolute path + } + + local hide_in_width = function() + return vim.fn.winwidth(0) > 100 + end + + local diagnostics = { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + sections = { 'error', 'warn' }, + symbols = { error = ' ', warn = ' ', info = ' ', hint = ' ' }, + colored = false, + update_in_insert = false, + always_visible = false, + cond = hide_in_width, + } + + local diff = { + 'diff', + colored = false, + symbols = { added = ' ', modified = ' ', removed = ' ' }, -- changes diff symbols + cond = hide_in_width, + } + + require('lualine').setup { + options = { + icons_enabled = true, + theme = themes[env_var_nvim_theme], -- Set theme based on environment variable + -- Some useful glyphs: + -- https://www.nerdfonts.com/cheat-sheet + --         + section_separators = { left = '', right = '' }, + component_separators = { left = '', right = '' }, + disabled_filetypes = { 'alpha', 'neo-tree', 'Avante' }, + always_divide_middle = true, + }, + sections = { + lualine_a = { mode }, + lualine_b = { 'branch' }, + lualine_c = { filename }, + lualine_x = { diagnostics, diff, { 'encoding', cond = hide_in_width }, { 'filetype', cond = hide_in_width } }, + lualine_y = { 'location' }, + lualine_z = { 'progress' }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { { 'filename', path = 1 } }, + lualine_x = { { 'location', padding = 0 } }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = { 'fugitive' }, + } + end, +} diff --git a/lua/plugins/misc.lua b/lua/plugins/misc.lua new file mode 100644 index 00000000..68605db8 --- /dev/null +++ b/lua/plugins/misc.lua @@ -0,0 +1,58 @@ +-- Standalone plugins with less than 10 lines of config go here +return { + { + -- autoclose tags + 'windwp/nvim-ts-autotag', + }, + { + -- detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', + }, + { + -- Powerful Git integration for Vim + 'tpope/vim-fugitive', + }, + { + -- GitHub integration for vim-fugitive + 'tpope/vim-rhubarb', + }, + { + -- Hints keybinds + 'folke/which-key.nvim', + opts = { + -- win = { + -- border = { + -- { '┌', 'FloatBorder' }, + -- { '─', 'FloatBorder' }, + -- { '┐', 'FloatBorder' }, + -- { '│', 'FloatBorder' }, + -- { '┘', 'FloatBorder' }, + -- { '─', 'FloatBorder' }, + -- { '└', 'FloatBorder' }, + -- { '│', 'FloatBorder' }, + -- }, + -- }, + }, + }, + { + -- Autoclose parentheses, brackets, quotes, etc. + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, + opts = {}, + }, + { + -- Highlight todo, notes, etc in comments + 'folke/todo-comments.nvim', + event = 'VimEnter', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = { signs = false }, + }, + { + -- high-performance color highlighter + 'norcalli/nvim-colorizer.lua', + config = function() + require('colorizer').setup() + end, + }, +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 00000000..2172afcd --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,37 @@ +return { + { + 'nvim-neo-tree/neo-tree.nvim', + opts = { + window = { + position = 'right', -- Ensure Neo-Tree opens on the right + }, + filesystem = { + follow_current_file = true, -- Automatically reveal the current file + use_libuv_file_watcher = true, -- Auto-refresh when files change + filtered_items = { + visible = true, + show_hidden_count = true, + hide_dotfiles = false, + }, + }, + }, + keys = { + { + 'fe', + function() + vim.cmd 'Neotree toggle right' -- Open Neo-Tree on the right side + end, + desc = 'Toggle Neo-Tree (Right Side)', + }, + { + 'fE', + function() + vim.cmd 'Neotree focus' -- Focus on the Neo-Tree window + end, + desc = 'Focus Neo-Tree', + }, + { 'e', 'fe', desc = 'Toggle Neo-Tree', remap = true }, + { 'E', 'fE', desc = 'Focus Neo-Tree', remap = true }, + }, + }, +} diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua new file mode 100644 index 00000000..73e42ddf --- /dev/null +++ b/lua/plugins/none-ls.lua @@ -0,0 +1,55 @@ +-- Format on save and linters +return { + 'nvimtools/none-ls.nvim', + dependencies = { + 'nvimtools/none-ls-extras.nvim', + 'jayp0521/mason-null-ls.nvim', -- ensure dependencies are installed + }, + config = function() + local null_ls = require 'null-ls' + local formatting = null_ls.builtins.formatting -- to setup formatters + local diagnostics = null_ls.builtins.diagnostics -- to setup linters + + -- list of formatters & linters for mason to install + require('mason-null-ls').setup { + ensure_installed = { + 'checkmake', + 'prettier', -- ts/js formatter + 'stylua', -- lua formatter + 'eslint_d', -- ts/js linter + 'shfmt', + 'ruff', + }, + -- auto-install configured formatters & linters (with null-ls) + automatic_installation = true, + } + + local sources = { + diagnostics.checkmake, + formatting.prettier.with { filetypes = { 'html', 'json', 'yaml', 'markdown' } }, + formatting.stylua, + formatting.shfmt.with { args = { '-i', '4' } }, + require('none-ls.formatting.ruff').with { extra_args = { '--extend-select', 'I' } }, + require 'none-ls.formatting.ruff_format', + } + + local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) + null_ls.setup { + -- debug = true, -- Enable debug mode. Inspect logs with :NullLsLog. + sources = sources, + -- you can reuse a shared lspconfig on_attach callback here + on_attach = function(client, bufnr) + if client.supports_method 'textDocument/formatting' then + vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr } + vim.api.nvim_create_autocmd('BufWritePre', { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format { async = false } + end, + }) + end + end, + } + end, +} diff --git a/lua/plugins/snack.lua b/lua/plugins/snack.lua new file mode 100644 index 00000000..cec88415 --- /dev/null +++ b/lua/plugins/snack.lua @@ -0,0 +1,32 @@ +return { + { + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + bigfile = { enabled = true }, + explorer = { enabled = true }, + indent = { enabled = true }, + input = { enabled = true }, + picker = { enabled = true }, + notifier = { enabled = true }, + quickfile = { enabled = true }, + scope = { enabled = true }, + -- scroll = { enabled = true }, + statuscolumn = { enabled = true }, + words = { enabled = true }, + + image = { + enabled = true, -- force enable even if terminal isn't fully supported + backend = "magick", -- fallback backend for images + diagnostics = true, -- keep this on so you can see setup issues + auto_preview = false, -- if you don’t want inline previews on hover + view = "image", -- can be "image", "ascii", or "none" + max_height = 30, -- in rows + max_width = 50, -- in columns + use_dither = false, -- optional: enable dithered rendering + }, + }, + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 00000000..4d1f4e8d --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,118 @@ +-- Fuzzy Finder (files, lsp, etc) +return { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + 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', + }, + config = function() + local telescope = require 'telescope' + local actions = require 'telescope.actions' + local builtin = require 'telescope.builtin' + + require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = actions.move_selection_previous, -- move to prev result + [''] = actions.move_selection_next, -- move to next result + [''] = actions.select_default, -- open file + }, + n = { + ['q'] = actions.close, + }, + + }, + }, + pickers = { + find_files = { + file_ignore_patterns = { 'node_modules', '.git', '.venv', 'query.sql.go', '*_templ.go' }, + hidden = true, + }, + buffers = { + initial_mode = 'normal', + sort_lastused = true, + -- sort_mru = true, + mappings = { + n = { + ['d'] = actions.delete_buffer, + ['l'] = actions.select_default, + }, + }, + }, + }, + live_grep = { + file_ignore_patterns = { 'node_modules', '.git', '.venv' }, + additional_args = function(_) + return { '--hidden' } + end, + }, + path_display = { + filename_first = { + reverse_directories = true, + }, + }, + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + git_files = { + previewer = false, + }, + } + + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + vim.keymap.set('n', '?', builtin.oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', 'sb', builtin.buffers, { desc = '[S]earch existing [B]uffers' }) + vim.keymap.set('n', 'sm', builtin.marks, { desc = '[S]earch [M]arks' }) + vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', 'gc', builtin.git_commits, { desc = 'Search [G]it [C]ommits' }) + vim.keymap.set('n', 'gcf', builtin.git_bcommits, { desc = 'Search [G]it [C]ommits for current [F]ile' }) + vim.keymap.set('n', 'gb', builtin.git_branches, { desc = 'Search [G]it [B]ranches' }) + vim.keymap.set('n', 'gs', builtin.git_status, { desc = 'Search [G]it [S]tatus (diff view)' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + 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]resume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', '', require('telescope.builtin').find_files, { desc = '[ ] Search Files' }) + vim.keymap.set('n', 'sds', function() + builtin.lsp_document_symbols { + symbols = { 'Class', 'Function', 'Method', 'Constructor', 'Interface', 'Module', 'Property' }, + } + end, { desc = '[S]each LSP document [S]ymbols' }) + -- vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + 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' }) + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + end, +} diff --git a/lua/plugins/themes/nord.lua b/lua/plugins/themes/nord.lua new file mode 100644 index 00000000..d70765ef --- /dev/null +++ b/lua/plugins/themes/nord.lua @@ -0,0 +1,3 @@ +return { + { 'AvidDabbler/quantum.vim' }, +} diff --git a/lua/plugins/themes/onedark.lua b/lua/plugins/themes/onedark.lua new file mode 100644 index 00000000..60ec4753 --- /dev/null +++ b/lua/plugins/themes/onedark.lua @@ -0,0 +1,101 @@ +return { + 'navarasu/onedark.nvim', + commit = 'dd640f6', + priority = 1000, + config = function() + -- vim.cmd.colorscheme 'onedark' + + local config = { + -- Main options -- + style = 'dark', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light' + transparent = true, -- Show/hide background + term_colors = true, -- Change terminal color as per the selected theme style + ending_tildes = false, -- Show the end-of-buffer tildes. By default they are hidden + cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu + + -- toggle theme style --- + toggle_style_key = 'th', -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "ts" + toggle_style_list = { 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light' }, -- List of styles to toggle between + + -- Change code style --- + -- Options are italic, bold, underline, none + -- You can configure multiple style with comma separated, For e.g., keywords = 'italic,bold' + code_style = { + comments = 'italic', + keywords = 'none', + functions = 'none', + strings = 'none', + variables = 'none', + }, + + -- Lualine options -- + lualine = { + transparent = false, -- lualine center bar transparency + }, + + -- Custom Highlights -- + colors = { + -- purple = '#56b6c2', + }, -- Override default colors + highlights = {}, -- Override highlight groups + + -- Plugins Config -- + diagnostics = { + darker = true, -- darker colors for diagnostic + undercurl = true, -- use undercurl instead of underline for diagnostics + background = true, -- use background color for virtual text + }, + } + + local onedark = require 'onedark' + onedark.setup(config) + onedark.load() + + -- Make the background of diagnostics messages transparent + local set_diagnostics_bg_transparency = function() + vim.cmd [[highlight DiagnosticVirtualTextError guibg=none]] + vim.cmd [[highlight DiagnosticVirtualTextWarn guibg=none]] + vim.cmd [[highlight DiagnosticVirtualTextInfo guibg=none]] + vim.cmd [[highlight DiagnosticVirtualTextHint guibg=none]] + end + set_diagnostics_bg_transparency() + + -- Toggle background transparency + local toggle_transparency = function() + config.transparent = not config.transparent + onedark.setup(config) + onedark.load() + set_diagnostics_bg_transparency() + end + + vim.keymap.set('n', 'bg', toggle_transparency, { noremap = true, silent = true }) + end, +} + +-- OneDark colors +-- black = "#181a1f", +-- bg0 = "#282c34", +-- bg1 = "#31353f", +-- bg2 = "#393f4a", +-- bg3 = "#3b3f4c", +-- bg_d = "#21252b", +-- bg_blue = "#73b8f1", +-- bg_yellow = "#ebd09c", +-- fg = "#abb2bf", +-- purple = "#c678dd", +-- green = "#98c379", +-- orange = "#d19a66", +-- blue = "#61afef", +-- yellow = "#e5c07b", +-- cyan = "#56b6c2", +-- red = "#e86671", +-- grey = "#5c6370", +-- light_grey = "#848b98", +-- dark_cyan = "#2b6f77", +-- dark_red = "#993939", +-- dark_yellow = "#93691d", +-- dark_purple = "#8a3fa0", +-- diff_add = "#31392b", +-- diff_delete = "#382b2c", +-- diff_change = "#1c3448", +-- diff_text = "#2c5372", diff --git a/lua/plugins/themes/quantum.lua b/lua/plugins/themes/quantum.lua new file mode 100644 index 00000000..eaf92a43 --- /dev/null +++ b/lua/plugins/themes/quantum.lua @@ -0,0 +1,10 @@ +return { + { + 'AvidDabbler/quantum.vim', + priority = 1000, -- Ensure it's loaded first + lazy = false, -- Load immediately + config = function() + vim.cmd 'colorscheme quantum' -- Explicitly set the colorscheme + end, + }, +} diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua new file mode 100644 index 00000000..26714157 --- /dev/null +++ b/lua/plugins/toggleterm.lua @@ -0,0 +1,13 @@ +return { + 'akinsho/toggleterm.nvim', + version = '*', + config = function() + require('toggleterm').setup { + direction = 'float', -- Opens a floating terminal + shell = vim.o.shell, -- Uses the default shell + } + -- Keymap to open terminal with Ctrl+/ + vim.keymap.set('n', '', 'ToggleTerm direction=float', { noremap = true, silent = true }) + vim.keymap.set('t', '', 'ToggleTerm', { noremap = true, silent = true }) + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 00000000..1b18591f --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,108 @@ +-- Highlight, edit, and navigate code +return { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, + config = function() + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { + "latex", "scss", "svelte", "vue", "norg", "typst", + 'lua', + 'python', + 'javascript', + 'typescript', + 'vimdoc', + 'vim', + 'regex', + 'terraform', + 'sql', + 'dockerfile', + 'toml', + 'json', + 'java', + 'groovy', + 'go', + 'gitignore', + 'graphql', + 'yaml', + 'make', + 'cmake', + 'markdown', + 'markdown_inline', + 'bash', + 'tsx', + 'css', + 'html', + }, + + fold = { enable = true }, -- Enable folding + -- Autoinstall languages that are not installed + auto_install = true, + + 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', + }, + }, + }, + } + + -- Register additional file extensions + vim.filetype.add { extension = { tf = 'terraform' } } + vim.filetype.add { extension = { tfvars = 'terraform' } } + vim.filetype.add { extension = { pipeline = 'groovy' } } + vim.filetype.add { extension = { multibranch = 'groovy' } } + end, +} diff --git a/lua/plugins/vim-tmux-navigator.lua b/lua/plugins/vim-tmux-navigator.lua new file mode 100644 index 00000000..beee1418 --- /dev/null +++ b/lua/plugins/vim-tmux-navigator.lua @@ -0,0 +1,18 @@ +-- Copied config from https://github.com/christoomey/vim-tmux-navigator +return { + 'christoomey/vim-tmux-navigator', + cmd = { + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', + }, + keys = { + { '', 'TmuxNavigateLeft' }, + { '', 'TmuxNavigateDown' }, + { '', 'TmuxNavigateUp' }, + { '', 'TmuxNavigateRight' }, + { '', 'TmuxNavigatePrevious' }, + }, +} diff --git a/lua/plugins/zellij.lua b/lua/plugins/zellij.lua new file mode 100644 index 00000000..97a799e1 --- /dev/null +++ b/lua/plugins/zellij.lua @@ -0,0 +1,12 @@ +return { + "https://git.sr.ht/~swaits/zellij-nav.nvim", + lazy = true, + event = "VeryLazy", + keys = { + { "", "ZellijNavigateLeft", { silent = true, desc = "navigate left" } }, + { "", "ZellijNavigateDown", { silent = true, desc = "navigate down" } }, + { "", "ZellijNavigateUp", { silent = true, desc = "navigate up" } }, + { "", "ZellijNavigateRight", { silent = true, desc = "navigate right" } }, + }, + opts = {}, +} diff --git a/nvim-troubleshooting.md b/nvim-troubleshooting.md new file mode 100644 index 00000000..d7f26ef0 --- /dev/null +++ b/nvim-troubleshooting.md @@ -0,0 +1,9 @@ +# Troubleshooting Notes for Neovim Setup + +- Check generate health of Neovim setup. `:checkhealth` +- Update Treesitter. `:TSUpdate` +- Check LSP installation. `:Mason` +- Fix broken icons + - Download [nerdfix](https://github.com/loichyan/nerdfix) binary and unpack in home directory. + - Run `nerdfix check ` to check broken icons in a file + - Run `nerdfix fix ` to fix broken icons in a file