diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 86598b8d..b061e410 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -10,9 +10,11 @@ assignees: '' ## Before Reporting an Issue + - I have read the kickstart.nvim README.md. - I have read the appropriate plugin's documentation. - I have searched that this issue has not been reported before. +- I have ran `:checkhealth` and so no obvious issue. - [ ] **By checking this, I confirm that the above steps are completed. I understand leaving this unchecked will result in this report being closed immediately.** diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..2bf7fff8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,10 @@ +blank_issues_enabled: false + +contact_links: + - name: Help + url: https://github.com/nvim-lua/kickstart.nvim/discussions/categories/q-a + about: Ask the community for help + + - name: Ideas + url: https://github.com/nvim-lua/kickstart.nvim/discussions/categories/ideas + about: Share ideas for new features diff --git a/.github/workflows/stylua.yml b/.github/workflows/stylua.yml index 75db6c33..eb60303f 100644 --- a/.github/workflows/stylua.yml +++ b/.github/workflows/stylua.yml @@ -9,13 +9,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v6 with: ref: ${{ github.event.pull_request.head.sha }} - name: Stylua Check - uses: JohnnyMorganz/stylua-action@v3 + uses: JohnnyMorganz/stylua-action@v4 with: token: ${{ secrets.GITHUB_TOKEN }} version: latest args: --check . - diff --git a/.stylua.toml b/.stylua.toml index 139e9397..edfa5067 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -4,3 +4,4 @@ indent_type = "Spaces" indent_width = 2 quote_style = "AutoPreferSingle" call_parentheses = "None" +collapse_simple_statement = "Always" diff --git a/README.md b/README.md index 003ed28d..5f332e5c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,14 @@ A starting point for Neovim that is: Kickstart.nvim targets *only* the latest ['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest ['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. -If you are experiencing issues, please make sure you have the latest versions. +If you are experiencing issues, please make sure you have at least the latest +stable version. Most likely, you want to install neovim via a [package +manager](https://github.com/neovim/neovim/blob/master/INSTALL.md#install-from-package). +To check your neovim version, run `nvim --version` and make sure it is not +below the latest +['stable'](https://github.com/neovim/neovim/releases/tag/stable) version. If +your chosen install method only gives you an outdated version of neovim, find +alternative [installation methods below](#alternative-neovim-installation-methods). ### Install External Dependencies @@ -25,6 +32,7 @@ External Requirements: - Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) - [ripgrep](https://github.com/BurntSushi/ripgrep#installation), [fd-find](https://github.com/sharkdp/fd#installation) +- [tree-sitter CLI](https://github.com/tree-sitter/tree-sitter/blob/master/crates/cli/README.md#installation) - Clipboard tool (xclip/xsel/win32yank or other depending on the platform) - A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons - if you have it set `vim.g.have_nerd_font` in `init.lua` to true @@ -61,9 +69,9 @@ fork to your machine using one of the commands below, depending on your OS. > Your fork's URL will be something like this: > `https://github.com//kickstart.nvim.git` -You likely want to remove `lazy-lock.json` from your fork's `.gitignore` file -too - it's ignored in the kickstart repo to make maintenance easier, but it's -[recommended to track it in version control](https://lazy.folke.io/usage/lockfile). +You likely want to remove `nvim-pack-lock.json` from your fork's `.gitignore` +file too - it's ignored in the kickstart repo to make maintenance easier, but +it's recommended to track it in version control (see `:help vim.pack-lockfile`). #### Clone kickstart.nvim @@ -103,8 +111,10 @@ Start Neovim nvim ``` -That's it! Lazy will install all the plugins you have. Use `:Lazy` to view -the current plugin status. Hit `q` to close the window. +That's it! `vim.pack` will install all the plugins from your config. Use +`:lua vim.pack.update(nil, { offline = true })` to inspect plugin state and +`:lua vim.pack.update()` to fetch updates (`:write` applies updates, `:quit` +cancels them). #### Read The Friendly Documentation @@ -138,7 +148,8 @@ examples of adding popularly requested plugins. `~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim distribution that you would like to try out. * What if I want to "uninstall" this configuration: - * See [lazy.nvim uninstall](https://lazy.folke.io/usage#-uninstalling) information + * Remove your config directory and local data directory (for example, + `~/.config/nvim` and `~/.local/share/nvim`). * Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files? * The main purpose of kickstart is to serve as a teaching tool and a reference configuration that someone can easily use to `git clone` as a basis for their own. @@ -154,22 +165,41 @@ examples of adding popularly requested plugins. Below you can find OS specific install instructions for Neovim and dependencies. -After installing all the dependencies continue with the [Install Kickstart](#Install-Kickstart) step. +After installing all the dependencies continue with the [Install Kickstart](#install-kickstart) step. #### Windows Installation
Windows with Microsoft C++ Build Tools and CMake -Installation may require installing build tools and updating the run command for `telescope-fzf-native` +Kickstart's default config is make-only for `telescope-fzf-native.nvim`. +If `make` is unavailable, the plugin is skipped. -See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) +Recommended: install `make` (see the chocolatey section below). -This requires: +If you want a CMake-only setup, customize `init.lua` in two places: -- Install CMake and the Microsoft C++ Build Tools on Windows +1. Include `telescope-fzf-native.nvim` when `cmake` is available: ```lua -{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } +if vim.fn.executable 'make' == 1 or vim.fn.executable 'cmake' == 1 then + table.insert(plugins, gh 'nvim-telescope/telescope-fzf-native.nvim') +end ``` + +2. In the `PackChanged` hook, use CMake when `make` is unavailable: + +```lua +if name == 'telescope-fzf-native.nvim' then + if vim.fn.executable 'make' == 1 then + run_build(name, { 'make' }, ev.data.path) + elseif vim.fn.executable 'cmake' == 1 then + run_build(name, { 'cmake', '-S.', '-Bbuild', '-DCMAKE_BUILD_TYPE=Release' }, ev.data.path) + run_build(name, { 'cmake', '--build', 'build', '--config', 'Release', '--target', 'install' }, ev.data.path) + end + return +end +``` + +See `telescope-fzf-native` documentation for [build details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation).
Windows with gcc/make using chocolatey Alternatively, one can install gcc and make which don't require changing the config, @@ -185,7 +215,7 @@ winget install --accept-source-agreements chocolatey.chocolatey 2. install all requirements using choco, exit the previous cmd and open a new one so that choco path is set, and run in cmd as **admin**: ``` -choco install -y neovim git ripgrep wget fd unzip gzip mingw make +choco install -y neovim git ripgrep wget fd unzip gzip mingw make tree-sitter ```
WSL (Windows Subsystem for Linux) @@ -195,7 +225,7 @@ wsl --install wsl sudo add-apt-repository ppa:neovim-ppa/unstable -y sudo apt update -sudo apt install make gcc ripgrep unzip git xclip neovim +sudo apt install make gcc ripgrep fd-find tree-sitter-cli unzip git xclip neovim ```
@@ -205,14 +235,14 @@ sudo apt install make gcc ripgrep unzip git xclip neovim ``` sudo add-apt-repository ppa:neovim-ppa/unstable -y sudo apt update -sudo apt install make gcc ripgrep unzip git xclip neovim +sudo apt install make gcc ripgrep fd-find tree-sitter-cli unzip git xclip neovim ```
Debian Install Steps ``` sudo apt update -sudo apt install make gcc ripgrep unzip git xclip curl +sudo apt install make gcc ripgrep fd-find tree-sitter-cli unzip git xclip curl # Now we install nvim curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz @@ -228,14 +258,88 @@ sudo ln -sf /opt/nvim-linux-x86_64/bin/nvim /usr/local/bin/
Fedora Install Steps ``` -sudo dnf install -y gcc make git ripgrep fd-find unzip neovim +sudo dnf install -y gcc make git ripgrep fd-find tree-sitter-cli unzip neovim ```
Arch Install Steps ``` -sudo pacman -S --noconfirm --needed gcc make git ripgrep fd unzip neovim +sudo pacman -S --noconfirm --needed gcc make git ripgrep fd tree-sitter-cli unzip neovim ```
+### Alternative neovim installation methods + +For some systems it is not unexpected that the [package manager installation +method](https://github.com/neovim/neovim/blob/master/INSTALL.md#install-from-package) +recommended by neovim is significantly behind. If that is the case for you, +pick one of the following methods that are known to deliver fresh neovim versions very quickly. +They have been picked for their popularity and because they make installing and updating +neovim to the latest versions easy. You can also find more detail about the +available methods being discussed +[here](https://github.com/nvim-lua/kickstart.nvim/issues/1583). + + +
Bob + +[Bob](https://github.com/MordechaiHadad/bob) is a Neovim version manager for +all platforms. Simply install +[rustup](https://rust-lang.github.io/rustup/installation/other.html), +and run the following commands: + +```bash +rustup default stable +rustup update stable +cargo install bob-nvim +bob use stable +``` + +
+ +
Homebrew + +[Homebrew](https://brew.sh) is a package manager popular on Mac and Linux. +Simply install using [`brew install`](https://formulae.brew.sh/formula/neovim). + +
+ +
Flatpak + +Flatpak is a package manager for applications that allows developers to package their applications +just once to make it available on all Linux systems. Simply [install flatpak](https://flatpak.org/setup/) +and setup [flathub](https://flathub.org/setup) to [install neovim](https://flathub.org/apps/io.neovim.nvim). + +
+ +
asdf and mise-en-place + +[asdf](https://asdf-vm.com/) and [mise](https://mise.jdx.dev/) are tool version managers, +mostly aimed towards project-specific tool versioning. However both support managing tools +globally in the user-space as well: + +
mise + +[Install mise](https://mise.jdx.dev/getting-started.html), then run: + +```bash +mise plugins install neovim +mise use neovim@stable +``` + +
+ +
asdf + +[Install asdf](https://asdf-vm.com/guide/getting-started.html), then run: + +```bash +asdf plugin add neovim +asdf install neovim stable +asdf set neovim stable --home +asdf reshim neovim +``` + +
+ +
diff --git a/init.lua b/init.lua index c73fa1a8..54ed06ee 100644 --- a/init.lua +++ b/init.lua @@ -29,7 +29,7 @@ vim.g.have_nerd_font = true -- Key mappings -vim.g.mapleader = ' ' -- Set leader key to space +vim.g.mapleader = ' ' -- Set leader key to space vim.g.maplocalleader = ' ' -- Set local leader key (NEW) -- Make background transparent @@ -37,29 +37,29 @@ vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) vim.api.nvim_set_hl(0, 'NormalNC', { bg = 'none' }) vim.api.nvim_set_hl(0, 'EndOfBuffer', { bg = 'none' }) vim.api.nvim_set_hl(0, 'SignColumn', { bg = 'none' }) -- Make sign column transparent -vim.opt.number = true -- Line numbers +vim.opt.number = true -- Line numbers -- Basic settings vim.opt.relativenumber = true -- Relative line numbers -vim.opt.cursorline = true -- Highlight current line -vim.opt.wrap = false -- Don't wrap lines -vim.opt.scrolloff = 10 -- Keep 10 lines above/below cursor -vim.opt.sidescrolloff = 8 -- Keep 8 columns left/right of cursor +vim.opt.cursorline = true -- Highlight current line +vim.opt.wrap = false -- Don't wrap lines +vim.opt.scrolloff = 10 -- Keep 10 lines above/below cursor +vim.opt.sidescrolloff = 8 -- Keep 8 columns left/right of cursor -- Indentation -vim.opt.tabstop = 2 -- Tab width -vim.opt.shiftwidth = 2 -- Indent width -vim.opt.softtabstop = 2 -- Soft tab stop -vim.opt.expandtab = true -- Use spaces instead of tabs +vim.opt.tabstop = 2 -- Tab width +vim.opt.shiftwidth = 2 -- Indent width +vim.opt.softtabstop = 2 -- Soft tab stop +vim.opt.expandtab = true -- Use spaces instead of tabs vim.opt.smartindent = true -- Smart auto-indenting -vim.opt.autoindent = true -- Copy indent from current line +vim.opt.autoindent = true -- Copy indent from current line vim.o.breakindent = true -- Search settings vim.opt.ignorecase = true -- Case insensitive search -vim.opt.smartcase = true -- Case sensitive if uppercase in search -vim.opt.hlsearch = false -- Don't highlight search results -vim.opt.incsearch = true -- Show matches as you type +vim.opt.smartcase = true -- Case sensitive if uppercase in search +vim.opt.hlsearch = false -- Don't highlight search results +vim.opt.incsearch = true -- Show matches as you type -- Visual settings vim.opt.termguicolors = true -- Enable 24-bit colors @@ -83,37 +83,37 @@ vim.opt.listchars = { tab = ' ', trail = '·', nbsp = '␣' } -- Sets how white -- Folding settings vim.opt.foldmethod = 'expr' -- Use expression for folding -- vim.wo.vim.foldexpr = 'v:lua.vim.treesitter.foldexpr()' -- Use treesitter for folding -vim.opt.foldlevel = 99 -- Start with all folds open +vim.opt.foldlevel = 99 -- Start with all folds open -- File handling -vim.opt.backup = false -- Don't create backup files -vim.opt.writebackup = false -- Don't create backup before writing -vim.opt.swapfile = false -- Don't create swap files -vim.opt.undofile = true -- Persistent undo -vim.o.undofile = true -- Save undo history +vim.opt.backup = false -- Don't create backup files +vim.opt.writebackup = false -- Don't create backup before writing +vim.opt.swapfile = false -- Don't create swap files +vim.opt.undofile = true -- Persistent undo +vim.o.undofile = true -- Save undo history vim.opt.undodir = vim.fn.expand '~/.vim/undodir' -- Undo directory -vim.opt.updatetime = 250 -- Faster completion -vim.opt.timeoutlen = 500 -- Key timeout duration -vim.opt.ttimeoutlen = 0 -- Key code timeout -vim.opt.autoread = true -- Auto reload files changed outside vim -vim.opt.autowrite = false -- Don't auto save +vim.opt.updatetime = 250 -- Faster completion +vim.opt.timeoutlen = 500 -- Key timeout duration +vim.opt.ttimeoutlen = 0 -- Key code timeout +vim.opt.autoread = true -- Auto reload files changed outside vim +vim.opt.autowrite = false -- Don't auto save -- Behavior settings -vim.opt.hidden = true -- Allow hidden buffers -vim.opt.errorbells = false -- No error bells +vim.opt.hidden = true -- Allow hidden buffers +vim.opt.errorbells = false -- No error bells vim.opt.backspace = 'indent,eol,start' -- Better backspace behavior -vim.opt.autochdir = false -- Don't auto change directory -vim.opt.iskeyword:append '-' -- Treat dash as part of word -vim.opt.path:append '**' -- include subdirectories in search -vim.opt.selection = 'exclusive' -- Selection behavior -vim.opt.mouse = 'a' -- Enable mouse support +vim.opt.autochdir = false -- Don't auto change directory +vim.opt.iskeyword:append '-' -- Treat dash as part of word +vim.opt.path:append '**' -- include subdirectories in search +vim.opt.selection = 'exclusive' -- Selection behavior +vim.opt.mouse = 'a' -- Enable mouse support vim.opt.clipboard:append 'unnamedplus' -- Use system clipboard -vim.opt.modifiable = true -- Allow buffer modifications -vim.opt.encoding = 'UTF-8' -- Set encoding -vim.opt.splitbelow = true -- Horizontal splits go below -vim.opt.splitright = true -- Vertical splits go right +vim.opt.modifiable = true -- Allow buffer modifications +vim.opt.encoding = 'UTF-8' -- Set encoding +vim.opt.splitbelow = true -- Horizontal splits go below +vim.opt.splitright = true -- Vertical splits go right vim.o.inccommand = 'split' -vim.o.confirm = true -- Ask before closing (unsaved changes) +vim.o.confirm = true -- Ask before closing (unsaved changes) -- Sync clipboard between OS and Neovim. -- Schedule the setting after `UiEnter` because it can increase startup-time. @@ -123,6 +123,9 @@ vim.schedule(function() vim.o.clipboard = 'unnamedplus' end) +-- Don't show the mode, since it's already in the status line +vim.o.showmode = false + -- [[ Basic Keymaps ]] vim.keymap.set('n', 'Ss', 'SessionSave', { desc = 'Save session' }) @@ -166,8 +169,30 @@ vim.keymap.set('n', '^[[1;9l', 'L', { desc = 'Move window to the right' }) vim.keymap.set('n', '^[[1;9j', 'J', { desc = 'Move window to the lower' }) vim.keymap.set('n', '^[[1;9k', 'K', { desc = 'Move window to the upper' }) --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` + +vim.diagnostic.config { + update_in_insert = false, + severity_sort = true, + float = { border = 'rounded', source = 'if_many' }, + underline = { severity = { min = vim.diagnostic.severity.WARN } }, + + -- Can switch between these as you prefer + virtual_text = true, -- Text shows up at the end of the line + virtual_lines = false, -- Text shows up underneath the line, with virtual lines + + -- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d` + jump = { + on_jump = function(_, bufnr) + vim.diagnostic.open_float { + bufnr = bufnr, + scope = 'cursor', + focus = false, + } + end, + }, +} + +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) -- Center screen when jumping vim.keymap.set('n', 'n', 'nzzzv', { desc = 'Next search result (centered)' }) @@ -186,10 +211,10 @@ vim.keymap.set('n', 'bn', 'bnext', { desc = 'Next buffer' }) vim.keymap.set('n', 'bp', 'bprevious', { desc = 'Previous buffer' }) -- Move lines up/down --- vim.keymap.set('n', '', 'm .+1==', { desc = 'Move line down' }) --- vim.keymap.set('n', '', 'm .-2==', { desc = 'Move line up' }) --- vim.keymap.set('v', '', "m '>+1gv=gv", { desc = 'Move selection down' }) --- vim.keymap.set('v', '', "m '<-2gv=gv", { desc = 'Move selection up' }) +vim.keymap.set('n', '', 'm .+1==', { desc = 'Move line down' }) +vim.keymap.set('n', '', 'm .-2==', { desc = 'Move line up' }) +vim.keymap.set('v', '', "m '>+1gv=gv", { desc = 'Move selection down' }) +vim.keymap.set('v', '', "m '<-2gv=gv", { desc = 'Move selection up' }) -- Better indenting in visual mode vim.keymap.set('v', '<', 'tft', FloatingTerminal, { noremap = true, silent = true, desc = 'Toggle floating terminal' }) -vim.keymap.set('n', 'tt', 'horizontal terminal', { noremap = true, silent = true, desc = 'Toggle terminal' }) +vim.keymap.set('n', 'tt', 'horizontal terminal', + { noremap = true, silent = true, desc = 'Toggle terminal' }) vim.keymap.set('t', '', function() if terminal_state.is_open then vim.api.nvim_win_close(terminal_state.win, false) @@ -434,7 +461,7 @@ end, { noremap = true, silent = true, desc = 'Close floating terminal from termi -- Tab display settings vim.opt.showtabline = 1 -- Always show tabline (0=never, 1=when multiple tabs, 2=always) -vim.opt.tabline = '' -- Use default tabline (empty string uses built-in) +vim.opt.tabline = '' -- Use default tabline (empty string uses built-in) -- Transparent tabline appearance vim.cmd [[ @@ -496,50 +523,58 @@ vim.keymap.set('n', 'tL', close_tabs_left, { desc = 'Close tabs to the l vim.keymap.set('n', 'x', 'q', { desc = 'Smart close buffer/tab' }) --- [[ 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) +-- ============================================================ +-- SECTION 3: PLUGIN MANAGER INTRO +-- vim.pack intro, build hooks +-- ============================================================ +do + local function run_build(name, cmd, cwd) + local result = vim.system(cmd, { cwd = cwd }):wait() + if result.code ~= 0 then + local stderr = result.stderr or '' + local stdout = result.stdout or '' + local output = stderr ~= '' and stderr or stdout + if output == '' then output = 'No output from build command.' end + vim.notify(('Build failed for %s:\n%s'):format(name, output), vim.log.levels.ERROR) + end end + + -- This autocommand runs after a plugin is installed or updated and + -- runs the appropriate build command for that plugin if necessary. + -- + -- See `:help vim.pack-events` + vim.api.nvim_create_autocmd('PackChanged', { + callback = function(ev) + local name = ev.data.spec.name + local kind = ev.data.kind + if kind ~= 'install' and kind ~= 'update' then return end + + if name == 'telescope-fzf-native.nvim' and vim.fn.executable 'make' == 1 then + run_build(name, { 'make' }, ev.data.path) + return + end + + if name == 'LuaSnip' then + if vim.fn.has 'win32' ~= 1 and vim.fn.executable 'make' == 1 then + run_build(name, { 'make', 'install_jsregexp' }, + ev.data.path) + end + return + end + + if name == 'nvim-treesitter' then + if not ev.data.active then vim.cmd.packadd 'nvim-treesitter' end + vim.cmd 'TSUpdate' + return + end + end, + }) end ----@type vim.Option -local rtp = vim.opt.rtp -rtp:prepend(lazypath) --- [[ Configure and install plugins ]] -require('lazy').setup({ - { import = 'kickstart.plugins' }, - { import = 'kickstart.plugins.lsp' }, - { import = 'custom.plugins' }, - -- - -- In normal mode type `sh` then write `lazy.nvim-plugin` - -- you can continue same window with `sr` which resumes last telescope search -}, { - ui = { - -- If you are using a Nerd Font: set icons to an empty table which will use the - -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table - icons = vim.g.have_nerd_font and {} or { - cmd = '⌘', - config = '🛠', - event = '📅', - ft = '📂', - init = '⚙', - keys = '🗝', - plugin = '🔌', - runtime = '💻', - require = '🌙', - source = '📄', - start = '🚀', - task = '📌', - lazy = '💤 ', - }, - }, -}) +-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. +require 'kickstart.plugins' +require 'custom.plugins' require 'custom.after.transparency' diff --git a/lazy-lock.json b/lazy-lock.json deleted file mode 100644 index 11dfd605..00000000 --- a/lazy-lock.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "LazyVim": { "branch": "main", "commit": "459a4c3b1059671e766a46c7cc223827dc67e3d0" }, - "LuaSnip": { "branch": "master", "commit": "642b0c595e11608b4c18219e93b88d7637af27bc" }, - "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, - "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, - "fidget.nvim": { "branch": "main", "commit": "82404b196e73a00b1727a91903beef5ddc319d22" }, - "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, - "gitsigns.nvim": { "branch": "main", "commit": "2038c666bd9d8a0b7349a0b6ee00dc83104b9ecf" }, - "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, - "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, - "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, - "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, - "lazygit.nvim": { "branch": "main", "commit": "a04ad0dbc725134edbee3a5eea29290976695357" }, - "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, - "markview.nvim": { "branch": "main", "commit": "301e431c7b618235f5447d54465c70934bd33668" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "21c5b3ebeaa0412e28096bb0701434c51c1fbf76" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, - "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, - "miasma.nvim": { "branch": "main", "commit": "466456f08d1a114c983c0d24e8fc01339e3b0a27" }, - "mini.nvim": { "branch": "main", "commit": "ecb05c524a99490c95a8862eb5cb09b1e629ed42" }, - "nvim-dap": { "branch": "master", "commit": "531771530d4f82ad2d21e436e3cc052d68d7aebb" }, - "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, - "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, - "nvim-jdtls": { "branch": "master", "commit": "6e9d953f0b82bccdb834cfde0e893f3119c22592" }, - "nvim-lint": { "branch": "master", "commit": "fd87a7ab27ee0ce1b15b56c1250fc4668fe8ac58" }, - "nvim-lspconfig": { "branch": "master", "commit": "bfcc0171a43f22afa61d927ffe9fcb6cb85dc99e" }, - "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, - "nvim-treesitter-context": { "branch": "master", "commit": "b311b30818951d01f7b4bf650521b868b3fece16" }, - "nvim-treesitter-textobjects": { "branch": "main", "commit": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e" }, - "nvim-ts-autotag": { "branch": "main", "commit": "88c1453db4ba7dd24131086fe51fdf74e587d275" }, - "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, - "oklch-color-picker.nvim": { "branch": "master", "commit": "9b5db80d5f6af8fbc31bad29f69ad76f63154944" }, - "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "supermaven-nvim": { "branch": "main", "commit": "07d20fce48a5629686aefb0a7cd4b25e33947d50" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, - "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "9377230aa5305d9e9aca4ed8dadf1070fb4aa9fc" }, - "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "e930d0a46031645040d5492595b46cdf6ab3514f" }, - "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, - "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, - "vim-tmux-navigator": { "branch": "master", "commit": "e41c431a0c7b7388ae7ba341f01a0d217eb3a432" }, - "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } -} diff --git a/lazyvim.json b/lazyvim.json deleted file mode 100644 index dc3e179d..00000000 --- a/lazyvim.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extras": [ - - ], - "news": { - "NEWS.md": "11866" - }, - "version": 8 -} \ No newline at end of file diff --git a/lua/custom/plugins/autotags.lua b/lua/custom/plugins/autotags.lua index 2972cba7..74083516 100644 --- a/lua/custom/plugins/autotags.lua +++ b/lua/custom/plugins/autotags.lua @@ -1,25 +1,25 @@ -return { - 'windwp/nvim-ts-autotag', - dependencies = { 'nvim-treesitter/nvim-treesitter' }, - config = function() - require('nvim-ts-autotag').setup { - autotag = { - enable = true, - enable_rename = true, - enable_close = true, - enable_close_on_slash = true, - filetypes = { - 'html', - 'xml', - 'javascript', - 'javascriptreact', - 'typescript', - 'typescriptreact', - 'vue', - 'svelte', - }, - }, - } - end, - event = 'InsertEnter', -} +-- return { +-- 'windwp/nvim-ts-autotag', +-- dependencies = { 'nvim-treesitter/nvim-treesitter' }, +-- config = function() +-- require('nvim-ts-autotag').setup { +-- autotag = { +-- enable = true, +-- enable_rename = true, +-- enable_close = true, +-- enable_close_on_slash = true, +-- filetypes = { +-- 'html', +-- 'xml', +-- 'javascript', +-- 'javascriptreact', +-- 'typescript', +-- 'typescriptreact', +-- 'vue', +-- 'svelte', +-- }, +-- }, +-- } +-- end, +-- event = 'InsertEnter', +-- } diff --git a/lua/custom/plugins/color-picker.lua b/lua/custom/plugins/color-picker.lua index b7ebe7f1..80aeca95 100644 --- a/lua/custom/plugins/color-picker.lua +++ b/lua/custom/plugins/color-picker.lua @@ -1,17 +1,5 @@ -return { - 'eero-lehtinen/oklch-color-picker.nvim', - event = 'VeryLazy', - version = '*', - keys = { - -- One handed keymap recommended, you will be using the mouse - { - 'v', - function() - require('oklch-color-picker').pick_under_cursor() - end, - desc = 'Color pick under cursor', - }, - }, - ---@type oklch.Opts - opts = {}, -} +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'eero-lehtinen/oklch-color-picker.nvim' } + require('oklch-color-picker').setup {} +end diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua index fc8fc371..d41b5e9b 100644 --- a/lua/custom/plugins/harpoon.lua +++ b/lua/custom/plugins/harpoon.lua @@ -1,76 +1,78 @@ -return { - 'ThePrimeagen/harpoon', - cmd = 'Harpoon', - keys = { - { - 'hh', - 'lua require("harpoon.ui").toggle_quick_menu()', - desc = 'Toggle Harpoon Quick Menu', - }, - { - 'ha', - 'lua require("harpoon.mark").add_file()', - desc = 'Mark Current File', - }, - { - 'hr', - 'lua require("harpoon.mark").clear_file()', - desc = 'Remove Current File', - }, - { - 'hn', - 'lua require("harpoon.ui").nav_next()', - desc = 'Next Harpoon', - }, - { - 'hp', - 'lua require("harpoon.ui").nav_prev()', - desc = 'Previous Harpoon', - }, - { - 'h&', - 'lua require("harpoon.ui").nav_file(1)', - desc = 'Go to 1st Mark', - }, - { - 'hé', - 'lua require("harpoon.ui").nav_file(2)', - desc = 'Go to 2nd Mark', - }, - { - 'h"', - 'lua require("harpoon.ui").nav_file(3)', - desc = 'Go to 3rd Mark', - }, - { - "h'", - 'lua require("harpoon.ui").nav_file(4)', - desc = 'Go to 4th Mark', - }, - { - 'h(', - 'lua require("harpoon.ui").nav_file(5)', - desc = 'Go to 5th Mark', - }, - { - 'h§', - 'lua require("harpoon.ui").nav_file(6)', - desc = 'Go to 6th Mark', - }, - { - 'hè', - 'lua require("harpoon.ui").nav_file(7)', - desc = 'Go to 7th Mark', - }, - { - 'h!', - 'lua require("harpoon.ui").nav_file(8)', - desc = 'Go to 8th Mark', - }, - { - 'hç', - 'lua require("harpoon.ui").nav_file(9)', - desc = 'Go to 9th Mark', - }, - }, -} +-- local function gh(repo) return 'https://github.com/' .. repo end +-- do +-- vim.pack.add { { src = gh 'ThePrimeagen/harpoon', branch = "harpoon2" }, gh "nvim-lua/plenary.nvim" } +-- require('harpoon').setup { +-- keys = { +-- { +-- 'hh', +-- 'lua require("harpoon.ui").toggle_quick_menu()', +-- desc = 'Toggle Harpoon Quick Menu', +-- }, +-- { +-- 'ha', +-- 'lua require("harpoon.mark").add_file()', +-- desc = 'Mark Current File', +-- }, +-- { +-- 'hr', +-- 'lua require("harpoon.mark").clear_file()', +-- desc = 'Remove Current File', +-- }, +-- { +-- 'hn', +-- 'lua require("harpoon.ui").nav_next()', +-- desc = 'Next Harpoon', +-- }, +-- { +-- 'hp', +-- 'lua require("harpoon.ui").nav_prev()', +-- desc = 'Previous Harpoon', +-- }, +-- { +-- 'h&', +-- 'lua require("harpoon.ui").nav_file(1)', +-- desc = 'Go to 1st Mark', +-- }, +-- { +-- 'hé', +-- 'lua require("harpoon.ui").nav_file(2)', +-- desc = 'Go to 2nd Mark', +-- }, +-- { +-- 'h"', +-- 'lua require("harpoon.ui").nav_file(3)', +-- desc = 'Go to 3rd Mark', +-- }, +-- { +-- "h'", +-- 'lua require("harpoon.ui").nav_file(4)', +-- desc = 'Go to 4th Mark', +-- }, +-- { +-- 'h(', +-- 'lua require("harpoon.ui").nav_file(5)', +-- desc = 'Go to 5th Mark', +-- }, +-- { +-- 'h§', +-- 'lua require("harpoon.ui").nav_file(6)', +-- desc = 'Go to 6th Mark', +-- }, +-- { +-- 'hè', +-- 'lua require("harpoon.ui").nav_file(7)', +-- desc = 'Go to 7th Mark', +-- }, +-- { +-- 'h!', +-- 'lua require("harpoon.ui").nav_file(8)', +-- desc = 'Go to 8th Mark', +-- }, +-- { +-- 'hç', +-- 'lua require("harpoon.ui").nav_file(9)', +-- desc = 'Go to 9th Mark', +-- }, +-- } +-- } +-- end diff --git a/lua/custom/plugins/hidden-diagnostic.lua b/lua/custom/plugins/hidden-diagnostic.lua index 861c621a..940a46e9 100644 --- a/lua/custom/plugins/hidden-diagnostic.lua +++ b/lua/custom/plugins/hidden-diagnostic.lua @@ -1,11 +1,11 @@ -return { - 'rachartier/tiny-inline-diagnostic.nvim', - event = 'VeryLazy', - priority = 1000, - config = function() - require('tiny-inline-diagnostic').setup() - vim.diagnostic.config { - virtual_text = false, - } -- Only if needed in your configuration, if you already have native LSP diagnostics - end, -} +-- return { +-- 'rachartier/tiny-inline-diagnostic.nvim', +-- event = 'VeryLazy', +-- priority = 1000, +-- config = function() +-- require('tiny-inline-diagnostic').setup() +-- vim.diagnostic.config { +-- virtual_text = false, +-- } -- Only if needed in your configuration, if you already have native LSP diagnostics +-- end, +-- } diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua new file mode 100644 index 00000000..01e91722 --- /dev/null +++ b/lua/custom/plugins/init.lua @@ -0,0 +1,13 @@ +-- 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 + +-- Iterate over all Lua files in the plugins directory and load them +local plugins_dir = vim.fs.joinpath(vim.fn.stdpath 'config', 'lua', 'custom', 'plugins') +for file_name, type in vim.fs.dir(plugins_dir, { follow = true }) do + if (type == 'file' or type == 'link') and file_name:match '%.lua$' and file_name ~= 'init.lua' then + local module = file_name:gsub('%.lua$', '') + require('custom.plugins.' .. module) + end +end diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua deleted file mode 100644 index 298465da..00000000 --- a/lua/custom/plugins/lazygit.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - 'kdheepak/lazygit.nvim', - lazy = true, - 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 = { - { 'gg', 'LazyGit', desc = 'LazyGit' }, - }, -} diff --git a/lua/custom/plugins/markdown.lua b/lua/custom/plugins/markdown.lua index a7da789e..d71fd515 100644 --- a/lua/custom/plugins/markdown.lua +++ b/lua/custom/plugins/markdown.lua @@ -1,5 +1,8 @@ -return { - 'OXY2DEV/markview.nvim', - lazy = false, - dependencies = { 'saghen/blink.cmp' }, -} +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { + gh 'OXY2DEV/markview.nvim', + gh 'saghen/blink.lib', + gh 'saghen/blink.cmp' + } +end diff --git a/lua/custom/plugins/supermaven.lua b/lua/custom/plugins/supermaven.lua index 318654c3..522b37a0 100644 --- a/lua/custom/plugins/supermaven.lua +++ b/lua/custom/plugins/supermaven.lua @@ -1,22 +1,21 @@ -return { - 'supermaven-inc/supermaven-nvim', - config = function() - require('supermaven-nvim').setup { - keymaps = { - accept_suggestion = '', - clear_suggestion = '', - accept_word = '', - }, - ignore_filetypes = { cpp = true }, -- or { "cpp", } - color = { - cterm = 244, - }, - log_level = 'info', -- set to "off" to disable logging completely - disable_inline_completion = false, -- disables inline completion for use with cmp - disable_keymaps = false, -- disables built in keymaps for more manual control - condition = function() - return false - end, -- condition to check for stopping supermaven, `true` means to stop supermaven when the condition is true.} - } - end, -} +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'supermaven-inc/supermaven-nvim' } + require('supermaven-nvim').setup { + keymaps = { + accept_suggestion = '', + clear_suggestion = '', + accept_word = '', + }, + ignore_filetypes = { cpp = true }, -- or { "cpp", } + color = { + cterm = 244, + }, + log_level = 'info', -- set to "off" to disable logging completely + disable_inline_completion = false, -- disables inline completion for use with cmp + disable_keymaps = false, -- disables built in keymaps for more manual control + condition = function() + return false + end, -- condition to check for stopping supermaven, `true` means to stop supermaven when the condition is true.} + } +end diff --git a/lua/custom/plugins/tmux-navigator.lua b/lua/custom/plugins/tmux-navigator.lua index 26fb72ba..e5d2856a 100644 --- a/lua/custom/plugins/tmux-navigator.lua +++ b/lua/custom/plugins/tmux-navigator.lua @@ -1,18 +1,9 @@ -return { - 'christoomey/vim-tmux-navigator', - cmd = { - 'TmuxNavigateLeft', - 'TmuxNavigateDown', - 'TmuxNavigateUp', - 'TmuxNavigateRight', - 'TmuxNavigatePrevious', - 'TmuxNavigatorProcessList', - }, - keys = { - { '', 'TmuxNavigateLeft' }, - { '', 'TmuxNavigateDown' }, - { '', 'TmuxNavigateUp' }, - { '', 'TmuxNavigateRight' }, - { '', 'TmuxNavigatePrevious' }, - }, -} +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'christoomey/vim-tmux-navigator' } + vim.keymap.set('n', '', 'TmuxNavigateLeft') + vim.keymap.set('n', '', 'TmuxNavigateDown') + vim.keymap.set('n', '', 'TmuxNavigateUp') + vim.keymap.set('n', '', 'TmuxNavigateRight') + vim.keymap.set('n', '', 'TmuxNavigatePrevious') +end diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua index 018799e5..3dce8681 100644 --- a/lua/custom/plugins/trouble.lua +++ b/lua/custom/plugins/trouble.lua @@ -1,48 +1,48 @@ -return { - 'folke/trouble.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - cmd = { 'Trouble' }, - opts = {}, -- Use default options - keys = { - { - 'dt', - 'Trouble diagnostics toggle', - desc = 'Toggle Diagnostics', +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'folke/trouble.nvim' } + require('trouble').setup { + keys = { + { + 'dt', + 'Trouble diagnostics toggle', + desc = 'Toggle Diagnostics', + }, + { + 'db', + 'Trouble diagnostics toggle filter.buf=0', + desc = 'Toggle Buffer Diagnostics', + }, + { + 'qq', + 'Trouble quickfix toggle', + desc = 'Toggle Quickfix List', + }, + { + 'qn', + 'cnext', + desc = 'Diagnostic Next', + }, + { + 'qp', + 'cprevious', + desc = 'Diagnostic Previous', + }, + { + 'ql', + 'Trouble loclist toggle', + desc = 'Toggle Location List', + }, + { + 'qc', + ':lua vim.fn.setqflist({}, "r")', + desc = 'Clear Quickfix List', + }, + { + 'qR', + 'Trouble lsp toggle focus=false win.position=right', + desc = 'Toggle LSP References', + }, }, - { - 'db', - 'Trouble diagnostics toggle filter.buf=0', - desc = 'Toggle Buffer Diagnostics', - }, - { - 'qq', - 'Trouble quickfix toggle', - desc = 'Toggle Quickfix List', - }, - { - 'qn', - 'cnext', - desc = 'Diagnostic Next', - }, - { - 'qp', - 'cprevious', - desc = 'Diagnostic Previous', - }, - { - 'ql', - 'Trouble loclist toggle', - desc = 'Toggle Location List', - }, - { - 'qc', - ':lua vim.fn.setqflist({}, "r")', - desc = 'Clear Quickfix List', - }, - { - 'qR', - 'Trouble lsp toggle focus=false win.position=right', - desc = 'Toggle LSP References', - }, - }, -} + } +end diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua index b59d0864..99102381 100644 --- a/lua/kickstart/health.lua +++ b/lua/kickstart/health.lua @@ -12,7 +12,7 @@ local check_version = function() return end - if vim.version.ge(vim.version(), '0.10-dev') then + if vim.version.ge(vim.version(), '0.12') 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)) diff --git a/lua/kickstart/plugins/auto-completion.lua b/lua/kickstart/plugins/auto-completion.lua index fd34bf36..0e42e30d 100644 --- a/lua/kickstart/plugins/auto-completion.lua +++ b/lua/kickstart/plugins/auto-completion.lua @@ -1,15 +1,10 @@ -- Autocompletion -return { - 'saghen/blink.cmp', - event = 'VimEnter', - version = '1.*', - dependencies = { - 'L3MON4D3/LuaSnip', - 'folke/lazydev.nvim', - }, - --- @module 'blink.cmp' - --- @type blink.cmp.Config - opts = { +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add({ gh 'saghen/blink.lib' }) + vim.pack.add { { src = gh 'saghen/blink.cmp', version = vim.version.range '2.*' } } + vim.pack.add { { src = gh 'saghen/blink.cmp', version = vim.version.range '1.*' } } + require('blink.cmp').setup { keymap = { -- 'default' (recommended) for mappings similar to built-in completions -- to accept ([y]es) the completion. @@ -61,10 +56,7 @@ return { }, sources = { - default = { 'lsp', 'path', 'snippets', 'lazydev', 'buffer' }, - providers = { - lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, - }, + default = { 'lsp', 'path', 'snippets', 'buffer' }, }, snippets = { preset = 'luasnip' }, @@ -80,5 +72,5 @@ return { -- Shows a signature help window while you type arguments for a function signature = { enabled = true }, - }, -} + } +end diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua new file mode 100644 index 00000000..7c986407 --- /dev/null +++ b/lua/kickstart/plugins/autopairs.lua @@ -0,0 +1,7 @@ +-- autopairs +-- https://github.com/windwp/nvim-autopairs +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'windwp/nvim-autopairs' } + require('nvim-autopairs').setup {} +end diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 5838d0f7..532a7da5 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -5,144 +5,95 @@ -- 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 ;) +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { + gh 'mfussenegger/nvim-dap', + gh 'rcarriga/nvim-dap-ui', + gh 'nvim-neotest/nvim-nio', + gh 'mason-org/mason.nvim', + gh 'jay-babu/mason-nvim-dap.nvim', + gh 'leoluz/nvim-dap-go', + } -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', + -- Basic debugging keymaps, feel free to change to your liking! + vim.keymap.set('n', '', function() require('dap').continue() end, { desc = 'Debug: Start/Continue' }) + vim.keymap.set('n', '', function() require('dap').step_into() end, { desc = 'Debug: Step Into' }) + vim.keymap.set('n', '', function() require('dap').step_over() end, { desc = 'Debug: Step Over' }) + vim.keymap.set('n', '', function() require('dap').step_out() end, { desc = 'Debug: Step Out' }) + vim.keymap.set('n', 'b', function() require('dap').toggle_breakpoint() end, + { desc = 'Debug: Toggle Breakpoint' }) + vim.keymap.set('n', '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. + vim.keymap.set('n', '', function() require('dapui').toggle() end, { desc = 'Debug: See last session result.' }) - -- Required dependency for nvim-dap-ui - 'nvim-neotest/nvim-nio', + local dap = require 'dap' + local dapui = require 'dapui' - -- Installs the debug adapters for you - 'mason-org/mason.nvim', - 'jay-babu/mason-nvim-dap.nvim', + require('mason-nvim-dap').setup { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_installation = true, - -- 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', - }, - { - 'Db', - function() - require('dap').toggle_breakpoint() - end, - desc = 'Debug: Toggle Breakpoint', - }, - { - 'DB', - 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' + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + handlers = {}, - require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations - automatic_installation = true, + -- 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', + }, + } - -- 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| + ---@diagnostic disable-next-line: missing-fields + 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 = '*' }, + ---@diagnostic disable-next-line: missing-fields + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', }, - } + }, + } - -- 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 - -- 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 - 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, -} + -- 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/format.lua b/lua/kickstart/plugins/format.lua index 804b31e9..da3f6358 100644 --- a/lua/kickstart/plugins/format.lua +++ b/lua/kickstart/plugins/format.lua @@ -1,32 +1,15 @@ -return { -- Autoformat - 'stevearc/conform.nvim', - event = { 'BufWritePre' }, - cmd = { 'ConformInfo' }, - keys = { - { - '=', - function() - require('conform').format { async = true, lsp_format = 'fallback' } - end, - mode = '', - desc = '[F]ormat buffer', - }, - }, - opts = { +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'stevearc/conform.nvim' } + require('conform').setup { 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 slow_filetypes = { kotlin = true } + local disable_filetypes = {} if disable_filetypes[vim.bo[bufnr].filetype] then return nil - elseif slow_filetypes[vim.bo[bufnr].filetype] then - return { - timeout_ms = 2500, - lsp_format = 'fallback', - } else return { timeout_ms = 500, @@ -63,5 +46,8 @@ return { -- Autoformat c = { 'clang-format' }, python = { 'black' }, }, - }, -} + } + + vim.keymap.set({ 'n', 'v' }, 'f', function() require('conform').format { async = true } end, + { desc = '[F]ormat buffer' }) +end diff --git a/lua/kickstart/plugins/git-signs.lua b/lua/kickstart/plugins/git-signs.lua deleted file mode 100644 index 35208168..00000000 --- a/lua/kickstart/plugins/git-signs.lua +++ /dev/null @@ -1,13 +0,0 @@ --- Adds git related signs to the gutter, as well as utilities for managing changes -return { - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, -} diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua index 8426f8ad..63ebbfde 100644 --- a/lua/kickstart/plugins/gitsigns.lua +++ b/lua/kickstart/plugins/gitsigns.lua @@ -2,60 +2,62 @@ -- 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 gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'lewis6991/gitsigns.nvim' } - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) + require('gitsigns').setup { + 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' }) - -- 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' }) - 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', 'gs', function() gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } end, + { desc = 'git [s]tage hunk' }) + map('v', 'gr', function() gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } end, + { desc = 'git [r]eset hunk' }) + -- normal mode + map('n', 'gs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) + map('n', 'gr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) + map('n', 'gS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) + map('n', 'gR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) + map('n', 'gp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) + map('n', 'gi', gitsigns.preview_hunk_inline, { desc = 'git preview hunk [i]nline' }) + map('n', 'gb', function() gitsigns.blame_line { full = true } end, { desc = 'git [b]lame line' }) + map('n', 'gd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) + map('n', 'gD', function() gitsigns.diffthis '@' end, { desc = 'git [D]iff against last commit' }) + map('n', 'gQ', function() gitsigns.setqflist 'all' end, + { desc = 'git hunk [Q]uickfix list (all files in repo)' }) + map('n', 'gq', gitsigns.setqflist, { desc = 'git hunk [q]uickfix list (all changes in this file)' }) + -- Toggles + map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) + map('n', 'tw', gitsigns.toggle_word_diff, { desc = '[T]oggle git intra-line [w]ord diff' }) - -- 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', 'gs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) - map('n', 'gr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) - map('n', 'gS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) - map('n', 'gu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' }) - map('n', 'gR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) - map('n', 'gp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) - map('n', 'gb', gitsigns.blame_line, { desc = 'git [b]lame line' }) - map('n', 'gd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) - map('n', 'gD', function() - gitsigns.diffthis '@' - end, { desc = 'git [D]iff against last commit' }) - -- Toggles - map('n', 'tgb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) - map('n', 'tgD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' }) - end, - }, - }, -} + -- Text object + map({ 'o', 'x' }, 'ih', gitsigns.select_hunk) + end, + } +end diff --git a/lua/kickstart/plugins/guess-indent.lua b/lua/kickstart/plugins/guess-indent.lua index 0cdf312f..8e9d745d 100644 --- a/lua/kickstart/plugins/guess-indent.lua +++ b/lua/kickstart/plugins/guess-indent.lua @@ -1,3 +1,6 @@ -return { - 'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically -} +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { + gh 'NMAC427/guess-indent.nvim' -- Detect tabstop and shiftwidth automatically + } +end diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/kickstart/plugins/indent_line.lua index ed7f2693..3ee8a8c5 100644 --- a/lua/kickstart/plugins/indent_line.lua +++ b/lua/kickstart/plugins/indent_line.lua @@ -1,9 +1,7 @@ -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 = {}, - }, -} +-- Add indentation guides even on blank lines + +-- Enable `lukas-reineke/indent-blankline.nvim` +-- See `:help ibl` +local function gh(repo) return 'https://github.com/' .. repo end +vim.pack.add { gh 'lukas-reineke/indent-blankline.nvim' } +require('ibl').setup {} diff --git a/lua/kickstart/plugins/init.lua b/lua/kickstart/plugins/init.lua new file mode 100644 index 00000000..23be5670 --- /dev/null +++ b/lua/kickstart/plugins/init.lua @@ -0,0 +1,13 @@ +-- 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 + +-- Iterate over all Lua files in the plugins directory and load them +local plugins_dir = vim.fs.joinpath(vim.fn.stdpath 'config', 'lua', 'kickstart', 'plugins') +for file_name, type in vim.fs.dir(plugins_dir, { follow = true }) do + if (type == 'file' or type == 'link') and file_name:match '%.lua$' and file_name ~= 'init.lua' then + local module = file_name:gsub('%.lua$', '') + require('kickstart.plugins.' .. module) + end +end diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index 37e7c987..31f334f3 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -1,72 +1,34 @@ -return { +-- Linting +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'mfussenegger/nvim-lint' } - { -- Linting - 'mfussenegger/nvim-lint', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local lint = require 'lint' - lint.linters_by_ft = { - markdown = { 'markdownlint' }, - dockerfile = { 'hadolint' }, - json = { 'jsonlint' }, - rst = { 'vale' }, - text = { 'vale' }, - javascript = { 'eslint' }, - javascripttreact = { 'eslint' }, - typescript = { 'eslint' }, - svelte = { 'eslint_d' }, - kotlin = { 'ktlint' }, - terraform = { 'tflint' }, - } + local lint = require 'lint' + lint.linters_by_ft = { + markdown = { 'markdownlint' }, -- Make sure to install `markdownlint` via mason / npm + dockerfile = { 'hadolint' }, + json = { 'jsonlint' }, + rst = { 'vale' }, + text = { 'vale' }, + javascript = { 'eslint' }, + javascripttreact = { 'eslint' }, + typescript = { 'eslint' }, + svelte = { 'eslint_d' }, + kotlin = { 'ktlint' }, + terraform = { 'tflint' }, + ruby = { "ruby" }, + } - -- 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['markdown'] = nil - lint.linters_by_ft['dockerfile'] = nil - lint.linters_by_ft['json'] = nil - lint.linters_by_ft['rst'] = nil - lint.linters_by_ft['text'] = nil - lint.linters_by_ft['javascript'] = nil - lint.linters_by_ft['javascripttreact'] = nil - lint.linters_by_ft['typescript'] = nil - lint.linters_by_ft['typescriptreact'] = nil - lint.linters_by_ft['svelte'] = nil - lint.linters_by_ft['kotlin'] = nil - lint.linters_by_ft['terraform'] = 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.bo.modifiable then - lint.try_lint() - end - end, - }) + -- 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.bo.modifiable then lint.try_lint() end end, - }, -} + }) +end diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua new file mode 100644 index 00000000..a68981af --- /dev/null +++ b/lua/kickstart/plugins/lsp.lua @@ -0,0 +1,227 @@ +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'j-hui/fidget.nvim' } + require('fidget').setup {} + + + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map('grn', 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('gra', vim.lsp.buf.code_action, '[G]oto Code [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('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') + map('grs', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') + map('grw', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') + + -- 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('textDocument/documentHighlight', event.buf) 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('textDocument/inlayHint', event.buf) 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, + }) + + ---@type table + local servers = { + clangd = {}, + gopls = { + cmd = { 'gopls' }, + filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' }, + settings = { + gopls = { + completeUnimported = true, + usePlaceholders = true, + analyses = { + unusedparams = true, + }, + }, + }, + }, + pyright = {}, + rust_analyzer = {}, + ts_ls = {}, + vue_ls = {}, + eslint = {}, + yamlls = {}, + qmlls = {}, + html = { + filetypes = { 'html', 'htmldjango', 'htmldjango-template', 'htmljinja', 'htmlmin' }, + }, + kotlin_language_server = { + settings = { + kotlin = { + enabled = true, + debug = true, + languageVersion = '2.0', + jvmTarget = '21', + includeNonDeclarations = true, + noStdlib = false, + noReflect = false, + incremental = true, + buildServerMode = false, + compilerOptions = { + jvmTarget = '21', + apiVersion = '1.8', + languageVersion = '2.0', + }, + }, + }, + }, + + + stylua = {}, -- Used to format Lua code + + -- Special Lua Config, as recommended by neovim help docs + lua_ls = { + on_init = function(client) + client.server_capabilities.documentFormattingProvider = false -- Disable formatting (formatting is done by stylua) + + if client.workspace_folders then + local path = client.workspace_folders[1].name + if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + version = 'LuaJIT', + path = { 'lua/?.lua', 'lua/?/init.lua' }, + }, + workspace = { + checkThirdParty = false, + -- NOTE: this is a lot slower and will cause issues when working on your own configuration. + -- See https://github.com/neovim/nvim-lspconfig/issues/3189 + library = vim.tbl_extend('force', vim.api.nvim_get_runtime_file('', true), { + '${3rd}/luv/library', + '${3rd}/busted/library', + }), + }, + }) + end, + ---@type lspconfig.settings.lua_ls + settings = { + Lua = { + format = { enable = false }, -- Disable formatting (formatting is done by stylua) + }, + }, + }, + } + + vim.pack.add { + gh 'neovim/nvim-lspconfig', + gh 'mason-org/mason.nvim', + gh 'mason-org/mason-lspconfig.nvim', + gh 'WhoIsSethDaniel/mason-tool-installer.nvim', + } + + -- Automatically install LSPs and related tools to stdpath for Neovim + require('mason').setup {} + + -- 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. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + -- You can add other tools here that you want Mason to install + }) + + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + for name, server in pairs(servers) do + vim.lsp.config(name, server) + vim.lsp.enable(name) + end +end + +-- Diagnostic Config +-- See :help vim.diagnostic.Opts +vim.diagnostic.config { + severity_sort = true, + float = { border = 'rounded', source = 'if_many' }, + underline = { severity = vim.diagnostic.severity.ERROR }, + signs = vim.g.have_nerd_font and { + text = { + [vim.diagnostic.severity.ERROR] = '󰅚 ', + [vim.diagnostic.severity.WARN] = '󰀪 ', + [vim.diagnostic.severity.INFO] = '󰋽 ', + [vim.diagnostic.severity.HINT] = '󰌶 ', + }, + } or {}, + virtual_text = { + source = 'if_many', + spacing = 2, + format = function(diagnostic) + local diagnostic_message = { + [vim.diagnostic.severity.ERROR] = diagnostic.message, + [vim.diagnostic.severity.WARN] = diagnostic.message, + [vim.diagnostic.severity.INFO] = diagnostic.message, + [vim.diagnostic.severity.HINT] = diagnostic.message, + } + return diagnostic_message[diagnostic.severity] + end, + }, +} + + + +-- Globally configure all LSP floating preview popups (like hover, signature help, etc) +local open_floating_preview = vim.lsp.util.open_floating_preview +function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) + opts = opts or {} + opts.border = opts.border or 'rounded' -- Set border to rounded + return open_floating_preview(contents, syntax, opts, ...) +end diff --git a/lua/kickstart/plugins/lsp/jdtls.lua b/lua/kickstart/plugins/lsp/jdtls.lua deleted file mode 100644 index 45bdf3d2..00000000 --- a/lua/kickstart/plugins/lsp/jdtls.lua +++ /dev/null @@ -1,5 +0,0 @@ --- Java LSP -return { - 'mfussenegger/nvim-jdtls', - ft = { 'java', 'kotlin', 'kt' }, -} diff --git a/lua/kickstart/plugins/lsp/lazydev.lua b/lua/kickstart/plugins/lsp/lazydev.lua deleted file mode 100644 index 447ce668..00000000 --- a/lua/kickstart/plugins/lsp/lazydev.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - -- `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' } }, - }, - }, -} diff --git a/lua/kickstart/plugins/lsp/main-lsp.lua b/lua/kickstart/plugins/lsp/main-lsp.lua deleted file mode 100644 index 5a3f876b..00000000 --- a/lua/kickstart/plugins/lsp/main-lsp.lua +++ /dev/null @@ -1,241 +0,0 @@ -return { - -- 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({})` - { 'mason-org/mason.nvim', opts = {} }, - 'mason-org/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP. - { 'j-hui/fidget.nvim', opts = {} }, - - -- Allows extra capabilities provided by blink.cmp - 'saghen/blink.cmp', - }, - config = function() - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - local map = function(keys, func, desc, mode) - mode = mode or 'n' - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - map('grn', vim.lsp.buf.rename, '[R]e[n]ame') - map('gca', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) - map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - map('gi', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - map('gt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') - map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') - map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') - - -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) - ---@param client vim.lsp.Client - ---@param method vim.lsp.protocol.Method - ---@param bufnr? integer some lsp support methods only in specific files - ---@return boolean - local function client_supports_method(client, method, bufnr) - if vim.fn.has 'nvim-0.11' == 1 then - return client:supports_method(method, bufnr) - else - return client.supports_method(method, { bufnr = bufnr }) - end - end - - -- 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(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) 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 - - if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) 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, - }) - - -- Diagnostic Config - -- See :help vim.diagnostic.Opts - vim.diagnostic.config { - severity_sort = true, - float = { border = 'rounded', source = 'if_many' }, - underline = { severity = vim.diagnostic.severity.ERROR }, - signs = vim.g.have_nerd_font and { - text = { - [vim.diagnostic.severity.ERROR] = '󰅚 ', - [vim.diagnostic.severity.WARN] = '󰀪 ', - [vim.diagnostic.severity.INFO] = '󰋽 ', - [vim.diagnostic.severity.HINT] = '󰌶 ', - }, - } or {}, - virtual_text = { - source = 'if_many', - spacing = 2, - format = function(diagnostic) - local diagnostic_message = { - [vim.diagnostic.severity.ERROR] = diagnostic.message, - [vim.diagnostic.severity.WARN] = diagnostic.message, - [vim.diagnostic.severity.INFO] = diagnostic.message, - [vim.diagnostic.severity.HINT] = diagnostic.message, - } - return diagnostic_message[diagnostic.severity] - 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 blink.cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. - local capabilities = require('blink.cmp').get_lsp_capabilities() - local util = require 'lspconfig/util' - - local servers = { - clangd = {}, - gopls = { - capabilities = capabilities, - cmd = { 'gopls' }, - filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' }, - root_dir = util.root_pattern('go.work', 'go.mod', '.git'), - settings = { - gopls = { - completeUnimported = true, - usePlaceholders = true, - analyses = { - unusedparams = true, - }, - }, - }, - }, - 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 = { - capabilities = capabilities, - }, - vue_ls = {}, - eslint = {}, - yamlls = {}, - qmlls = { - capabilities = capabilities, - }, - html = { - filetypes = { 'html', 'htmldjango', 'htmldjango-template', 'htmljinja', 'htmlmin' }, - }, - - lua_ls = { - -- cmd = { ... }, - -- filetypes = { ... }, - -- capabilities = {}, - settings = { - Lua = { - completion = { - callSnippet = 'Replace', - }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - diagnostics = { - globals = { 'vim' }, - }, - -- diagnostics = { disable = { 'missing-fields' } }, - }, - }, - }, - kotlin_language_server = { - settings = { - kotlin = { - enabled = true, - debug = true, - languageVersion = '2.0', - jvmTarget = '21', - includeNonDeclarations = true, - noStdlib = false, - noReflect = false, - incremental = true, - buildServerMode = false, - compilerOptions = { - jvmTarget = '21', - apiVersion = '1.8', - languageVersion = '2.0', - }, - }, - }, - }, - } - - -- Ensure the servers and tools above are installed - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'stylua', -- Used to format Lua code - 'jdtls', - 'java-debug-adapter', - 'java-test', - }) - require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - require('mason-lspconfig').setup { - ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) - automatic_installation = false, - handlers = { - function(server_name) - -- Don't call setup for jdtls, it's already setup in the jdtls.lua file - 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 {}) - vim.lsp.config(server_name, server) - end, - }, - } - - -- Non Mason LSP servers - -- vim.lsp.enable 'kotlin_lsp' - -- vim.lsp.config('kotlin_lsp', { - -- capabilities = capabilities, - -- }) - - -- Globally configure all LSP floating preview popups (like hover, signature help, etc) - local open_floating_preview = vim.lsp.util.open_floating_preview - function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) - opts = opts or {} - opts.border = opts.border or 'rounded' -- Set border to rounded - return open_floating_preview(contents, syntax, opts, ...) - end - end, -} diff --git a/lua/kickstart/plugins/lualine.lua b/lua/kickstart/plugins/lualine.lua index fb495723..ee8cb560 100644 --- a/lua/kickstart/plugins/lualine.lua +++ b/lua/kickstart/plugins/lualine.lua @@ -1,45 +1,45 @@ -return { - 'nvim-lualine/lualine.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function() - require('lualine').setup { - options = { - theme = vim.g.colors_name or 'auto', - component_separators = '', - section_separators = { left = '', right = '' }, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - }, - }, - sections = { - lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 } }, - lualine_b = { 'branch', 'diagnostics' }, - lualine_c = { { 'filename', path = 1 } }, +-- return { +-- 'nvim-lualine/lualine.nvim', +-- dependencies = { 'nvim-tree/nvim-web-devicons' }, +-- config = function() +-- require('lualine').setup { +-- options = { +-- theme = vim.g.colors_name or 'auto', +-- component_separators = '', +-- section_separators = { left = '', right = '' }, +-- disabled_filetypes = { +-- statusline = {}, +-- winbar = {}, +-- }, +-- ignore_focus = {}, +-- globalstatus = false, +-- refresh = { +-- statusline = 1000, +-- tabline = 1000, +-- winbar = 1000, +-- }, +-- }, +-- sections = { +-- lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 } }, +-- lualine_b = { 'branch', 'diagnostics' }, +-- lualine_c = { { 'filename', path = 1 } }, - lualine_x = {}, - lualine_y = { 'filetype', 'progress' }, - lualine_z = { - { 'location', separator = { right = '' }, left_padding = 2 }, - }, - }, - inactive_sections = { - lualine_a = { 'filename' }, - lualine_b = {}, - lualine_c = {}, - lualine_x = {}, - lualine_y = {}, - lualine_z = { 'location' }, - }, - tabline = {}, - extensions = {}, - } - end, -} +-- lualine_x = {}, +-- lualine_y = { 'filetype', 'progress' }, +-- lualine_z = { +-- { 'location', separator = { right = '' }, left_padding = 2 }, +-- }, +-- }, +-- inactive_sections = { +-- lualine_a = { 'filename' }, +-- lualine_b = {}, +-- lualine_c = {}, +-- lualine_x = {}, +-- lualine_y = {}, +-- lualine_z = { 'location' }, +-- }, +-- tabline = {}, +-- extensions = {}, +-- } +-- end, +-- } diff --git a/lua/kickstart/plugins/mini.lua b/lua/kickstart/plugins/mini.lua index e59ce293..edf030c7 100644 --- a/lua/kickstart/plugins/mini.lua +++ b/lua/kickstart/plugins/mini.lua @@ -1,76 +1,110 @@ -- Collection of various small independent plugins/modules -return { - 'echasnovski/mini.nvim', - config = function() - require('mini.ai').setup { n_lines = 500 } - require('mini.surround').setup() - require('mini.move').setup() - require('mini.pairs').setup() - require('mini.bracketed').setup() - require('mini.notify').setup { - window = { - winblend = 0, - }, - } - local MiniFiles = require 'mini.files' - MiniFiles.setup { - mappings = { - go_out = '', - go_in = '', - go_in_plus = '', - synchronize = '', - }, - windows = { - preview = true, - width_preview = 100, - }, - } +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { gh 'echasnovski/mini.nvim' } - local minifiles_toggle = function(dir) - if not MiniFiles.close() then - MiniFiles.open(dir) - end + -- Better Around/Inside textobjects + -- + -- Examples: + -- - va) - [V]isually select [A]round [)]paren + -- - yiiq - [Y]ank [I]nside [I]+1 [Q]uote + -- - ci' - [C]hange [I]nside [']quote + require('mini.ai').setup { + -- NOTE: Avoid conflicts with the built-in incremental selection mappings on Neovim>=0.12 (see `:help treesitter-incremental-selection`) + mappings = { + around_next = 'aa', + inside_next = 'ii', + }, + n_lines = 500, + } + + if vim.g.have_nerd_font then + require('mini.icons').setup() + -- Used for backwards compatibility with plugins that require `nvim-web-devicons` (e.g. telescope.nvim) + MiniIcons.mock_nvim_web_devicons() + end + + -- 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/nvim-mini/mini.nvim + + require('mini.move').setup() + + require('mini.pairs').setup() + + require('mini.bracketed').setup() + + require('mini.notify').setup { + window = { + winblend = 0, + }, + } + + local MiniFiles = require 'mini.files' + MiniFiles.setup { + mappings = { + go_out = '', + go_in = '', + go_in_plus = '', + synchronize = '', + }, + windows = { + preview = true, + width_preview = 100, + }, + } + + local minifiles_toggle = function(dir) + if not MiniFiles.close() then + MiniFiles.open(dir) end + end - local open_file_in_minifiles = function() - minifiles_toggle(vim.fn.expand '%:p') + local open_file_in_minifiles = function() + minifiles_toggle(vim.fn.expand '%:p') + end + + local set_cwd = function() + local path = (MiniFiles.get_fs_entry() or {}).path + if path == nil then + return vim.notify('Cursor is not on valid entry', vim.log.levels.ERROR) end + vim.fn.chdir(vim.fs.dirname(path)) + end - local set_cwd = function() + -- Yank in register full path of entry under cursor + local yank_path = function() + if MiniFiles.get_explorer_state().target_window ~= nil then local path = (MiniFiles.get_fs_entry() or {}).path if path == nil then - return vim.notify 'Cursor is not on valid entry' + vim.notify('Cursor is not on valid entry', vim.log.levels.ERROR) end - vim.fn.chdir(vim.fs.dirname(path)) + vim.fn.setreg(vim.v.register, path) end + end - -- Yank in register full path of entry under cursor - local yank_path = function() - if MiniFiles.get_explorer_state().target_window ~= nil then - local path = (MiniFiles.get_fs_entry() or {}).path - if path == nil then - return vim.notify 'Cursor is not on valid entry' - end - vim.fn.setreg(vim.v.register, path) - end - end - - vim.keymap.set('n', 're', minifiles_toggle, { desc = 'Open Explorer in root' }) - vim.keymap.set('n', 'e', open_file_in_minifiles, { desc = 'Open Explorer in current file' }) - vim.keymap.set('n', 'cwd', set_cwd, { desc = 'Set cwd' }) - vim.keymap.set('n', 'yp', yank_path, { desc = 'Yank path' }) - vim.keymap.set('n', '', MiniFiles.go_in, { desc = 'Open file' }) - - 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 - end, -} + vim.keymap.set('n', 're', minifiles_toggle, { desc = 'Open Explorer in root' }) + vim.keymap.set('n', 'e', open_file_in_minifiles, { desc = 'Open Explorer in current file' }) + vim.keymap.set('n', 'cwd', set_cwd, { desc = 'Set cwd' }) + vim.keymap.set('n', 'yp', yank_path, { desc = 'Yank path' }) + vim.keymap.set('n', '', MiniFiles.go_in, { desc = 'Open file' }) +end diff --git a/lua/kickstart/plugins/snippets.lua b/lua/kickstart/plugins/snippets.lua index 236bca1e..1d77fe5f 100644 --- a/lua/kickstart/plugins/snippets.lua +++ b/lua/kickstart/plugins/snippets.lua @@ -1,51 +1,33 @@ -return { - 'L3MON4D3/LuaSnip', - event = 'VimEnter', - version = '2.*', - 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 +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { { src = gh 'L3MON4D3/LuaSnip', version = vim.version.range '2.*' } } + vim.pack.add { gh 'rafamadriz/friendly-snippets' } + require('luasnip.loaders.from_vscode').lazy_load() + local ls = require('luasnip') + ls.setup { + history = false, + updateevents = 'TextChanged,TextChangedI', + } + + for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*lua', true)) do + loadfile(ft_path)() + end + + vim.keymap.set({ 'i', 's' }, '', function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() end - return 'make install_jsregexp' - end)(), - dependencies = { - { - 'rafamadriz/friendly-snippets', - config = function() - require('luasnip.loaders.from_vscode').lazy_load() - end, - }, - }, - config = function() - local ls = require 'luasnip' - ls.config.set_config { - history = false, - updateevents = 'TextChanged,TextChangedI', - } + end, { silent = true }) - for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*lua', true)) do - loadfile(ft_path)() + vim.keymap.set({ 'i', 's' }, '', function() + if ls.jumpable(-1) then + ls.jump(-1) end + end, { silent = true }) - vim.keymap.set({ 'i', 's' }, '', function() - if ls.expand_or_jumpable() then - ls.expand_or_jump() - end - end, { silent = true }) - - vim.keymap.set({ 'i', 's' }, '', function() - if ls.jumpable(-1) then - ls.jump(-1) - end - end, { silent = true }) - - vim.keymap.set({ 'i', 's' }, '', function() - if ls.jumpable(1) then - ls.jump(1) - end - end, { silent = true }) - end, -} + vim.keymap.set({ 'i', 's' }, '', function() + if ls.jumpable(1) then + ls.jump(1) + end + end, { silent = true }) +end diff --git a/lua/kickstart/plugins/telescope.lua b/lua/kickstart/plugins/telescope.lua index a49547f0..c0aa16b0 100644 --- a/lua/kickstart/plugins/telescope.lua +++ b/lua/kickstart/plugins/telescope.lua @@ -1,127 +1,131 @@ -return { -- Fuzzy Finder (files, lsp, etc) - 'nvim-telescope/telescope.nvim', - event = 'VimEnter', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions - 'nvim-telescope/telescope-fzf-native.nvim', +local function gh(repo) return 'https://github.com/' .. repo end +do + ---@type (string|vim.pack.Spec)[] + local telescope_plugins = { + gh 'nvim-lua/plenary.nvim', + gh 'nvim-telescope/telescope.nvim', + gh 'nvim-telescope/telescope-ui-select.nvim', + } + if vim.fn.executable 'make' == 1 then table.insert(telescope_plugins, gh 'nvim-telescope/telescope-fzf-native.nvim') end - -- `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', + -- NOTE: You can install multiple plugins at once + vim.pack.add(telescope_plugins) - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, + local actions = require 'telescope.actions' + -- [[ 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 = { + layout_strategy = 'horizontal', + layout_config = { + width = 0.9, + height = 0.9, + }, + preview_width = 0.6, + + path_display = { 'truncate' }, + mappings = { + n = { + [''] = actions.add_selected_to_qflist + actions.open_qflist, + }, + i = { + [''] = 'to_fuzzy_refine', + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + [''] = actions.add_selection, + [''] = actions.add_selection, + [''] = actions.select_default, + [''] = actions.add_selected_to_qflist + actions.open_qflist, + [''] = actions.close, + }, + }, }, - { '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! - - local actions = require 'telescope.actions' - -- [[ 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 = { - layout_strategy = 'horizontal', - layout_config = { - width = 0.9, - height = 0.9, - }, - preview_width = 0.6, - - path_display = { 'truncate' }, - mappings = { - n = { - [''] = actions.add_selected_to_qflist + actions.open_qflist, - }, - i = { - [''] = 'to_fuzzy_refine', - [''] = actions.move_selection_next, - [''] = actions.move_selection_previous, - [''] = actions.add_selection, - [''] = actions.add_selection, - [''] = actions.select_default, - [''] = actions.add_selected_to_qflist + actions.open_qflist, - [''] = actions.close, - }, - }, + pickers = { + find_files = { + find_command = { 'rg', '--files', '--hidden', '--glob', '!**/.git/*' }, }, - pickers = { - find_files = { - find_command = { 'rg', '--files', '--hidden', '--glob', '!**/.git/*' }, - }, - }, - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, + }, + 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', 'fh', builtin.help_tags, { desc = '[F]ind [H]elp' }) + vim.keymap.set('n', 'fk', builtin.keymaps, { desc = '[F]ind [K]eymaps' }) + vim.keymap.set('n', 'ff', builtin.find_files, { desc = '[F]ind [F]iles' }) + vim.keymap.set('n', 'fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' }) + vim.keymap.set({ 'n', 'v' }, 'fw', builtin.grep_string, { desc = '[F]ind current [W]ord' }) + vim.keymap.set('n', 'fg', builtin.live_grep, { desc = '[F]ind by [G]rep' }) + vim.keymap.set('n', 'fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' }) + vim.keymap.set('n', 'f.', builtin.resume, { desc = '[F]ind [R]esume' }) + vim.keymap.set('n', 'fr', builtin.oldfiles, { desc = '[F]ind [R]ecent Files' }) + vim.keymap.set('n', 'fc', builtin.commands, { desc = '[F]ind [C]ommands' }) + vim.keymap.set('n', 'f', builtin.buffers, { desc = '[F]ind existing buffers' }) + + -- Add Telescope-based LSP pickers when an LSP attaches to a buffer. + -- If you later switch picker plugins, this is where to update these mappings. + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('telescope-lsp-attach', { clear = true }), + callback = function(event) + local buf = event.buf + + -- Find references for the word under your cursor. + vim.keymap.set('n', 'grr', builtin.lsp_references, { buffer = buf, desc = '[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. + vim.keymap.set('n', 'gri', builtin.lsp_implementations, { buffer = buf, desc = '[G]oto [I]mplementation' }) + + -- 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 . + vim.keymap.set('n', 'grd', builtin.lsp_definitions, { buffer = buf, desc = '[G]oto [D]efinition' }) + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + vim.keymap.set('n', 'gO', builtin.lsp_document_symbols, { buffer = buf, desc = 'Open Document Symbols' }) + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + vim.keymap.set('n', 'gW', builtin.lsp_dynamic_workspace_symbols, { buffer = buf, desc = 'Open Workspace Symbols' }) + + -- 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*. + vim.keymap.set('n', 'grt', builtin.lsp_type_definitions, { buffer = buf, desc = '[G]oto [T]ype Definition' }) + end, + }) + + -- 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 = true, + }) + 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', 'f/', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', } + end, { desc = '[F]ind [/] in Open Files' }) - -- 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', 'fh', builtin.help_tags, { desc = '[F]ind [H]elp' }) - vim.keymap.set('n', 'fk', builtin.keymaps, { desc = '[F]ind [K]eymaps' }) - vim.keymap.set('n', 'ff', builtin.find_files, { desc = '[F]ind [F]iles' }) - vim.keymap.set('n', 'fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' }) - vim.keymap.set('n', 'fw', builtin.grep_string, { desc = '[F]ind current [W]ord' }) - vim.keymap.set('n', 'fg', builtin.live_grep, { desc = '[F]ind by [G]rep' }) - vim.keymap.set('n', 'fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' }) - vim.keymap.set('n', 'f.', builtin.resume, { desc = '[F]ind [R]esume' }) - vim.keymap.set('n', 'fr', builtin.oldfiles, { desc = '[F]ind [R]ecent Files' }) - vim.keymap.set('n', 'f', 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 = true, - }) - 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', 'f/', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[F]ind [/] in Open Files' }) - - -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'fn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[F]ind [N]eovim files' }) - end, -} + -- Shortcut for searching your Neovim configuration files + vim.keymap.set('n', 'fn', function() + builtin.find_files { cwd = vim.fn.stdpath 'config' } + end, { desc = '[F]ind [N]eovim files' }) +end diff --git a/lua/kickstart/plugins/todo-comments.lua b/lua/kickstart/plugins/todo-comments.lua deleted file mode 100644 index 73b4202e..00000000 --- a/lua/kickstart/plugins/todo-comments.lua +++ /dev/null @@ -1,7 +0,0 @@ --- Highlight todo, notes, etc in comments -return { - 'folke/todo-comments.nvim', - event = 'VimEnter', - dependencies = { 'nvim-lua/plenary.nvim' }, - opts = { signs = false }, -} diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua index 9a7cfabc..8af7dcaa 100644 --- a/lua/kickstart/plugins/treesitter.lua +++ b/lua/kickstart/plugins/treesitter.lua @@ -1,43 +1,83 @@ -return { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - main = 'nvim-treesitter.configs', -- Sets main module to use for opts - dependencies = { - { 'nvim-treesitter/nvim-treesitter-textobjects' }, - { - 'nvim-treesitter/nvim-treesitter-context', - opts = { enable = true, mode = 'topline', line_numbers = true }, - }, - }, +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add { { src = gh 'nvim-treesitter/nvim-treesitter', version = 'main' } } + + local parsers = { + 'bash', + 'c', + 'diff', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'vim', + 'vimdoc', + 'go', + 'typescript', + 'javascript', + 'kotlin', + 'yaml', + 'html', + 'json', + 'markdown', + 'markdown_inline', + 'python', + 'rust', + 'toml', + 'yaml', + } + + require('nvim-treesitter').install(parsers) + + ---@param buf integer + ---@param language string + local function treesitter_try_attach(buf, language) + -- Check if a parser exists and load it + if not vim.treesitter.language.add(language) then return end + -- Enable syntax highlighting and other treesitter features + vim.treesitter.start(buf, language) + + -- Enable treesitter based folds + -- For more info on folds see `:help folds` + -- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' + -- vim.wo.foldmethod = 'expr' + + -- Check if treesitter indentation is available for this language, and if so enable it + -- in case there is no indent query, the indentexpr will fallback to the vim's built in one + local has_indent_query = vim.treesitter.query.get(language, 'indents') ~= nil + + -- Enable treesitter based indentation + if has_indent_query then vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end + end + + local available_parsers = require('nvim-treesitter').get_available() + vim.api.nvim_create_autocmd('FileType', { + callback = function(args) + local buf, filetype = args.buf, args.match + + local language = vim.treesitter.language.get_lang(filetype) + if not language then return end + + local installed_parsers = require('nvim-treesitter').get_installed 'parsers' + + if vim.tbl_contains(installed_parsers, language) then + -- Enable the parser if it is already installed + treesitter_try_attach(buf, language) + elseif vim.tbl_contains(available_parsers, language) then + -- If a parser is available in `nvim-treesitter`, auto-install it and enable it after the installation is done + require('nvim-treesitter').install(language):await(function() treesitter_try_attach(buf, language) end) + else + -- Try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` + treesitter_try_attach(buf, language) + end + end, + }) + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - opts = { - ensure_installed = { - 'bash', - 'c', - 'diff', - 'html', - 'lua', - 'luadoc', - 'markdown', - 'markdown_inline', - 'query', - 'vim', - 'vimdoc', - 'go', - 'typescript', - 'javascript', - 'kotlin', - 'yaml', - 'html', - 'json', - 'jsonc', - 'markdown', - 'markdown_inline', - -- 'python', - 'rust', - 'toml', - 'yaml', - }, + require('nvim-treesitter').setup { + ensure_installed = {}, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -61,12 +101,5 @@ return { -- Highlight, edit, and navigate code }, }, }, - }, - -- There are additional nvim-treesitter modules that you can use textobjectsto in - -- eract - -- 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 -} + } +end diff --git a/lua/kickstart/plugins/which-key.lua b/lua/kickstart/plugins/which-key.lua index 4cbc6853..2ea63eea 100644 --- a/lua/kickstart/plugins/which-key.lua +++ b/lua/kickstart/plugins/which-key.lua @@ -1,8 +1,8 @@ -- Useful plugin to show you pending keybinds. -return { - 'folke/which-key.nvim', - event = 'VimEnter', -- Sets the loading event to 'VimEnter' - opts = { +local function gh(repo) return 'https://github.com/' .. repo end +do + vim.pack.add({ gh 'folke/which-key.nvim' }) + require('which-key').setup { -- delay between pressing a key and opening which-key (milliseconds) -- this setting is independent of vim.o.timeoutlen delay = 0, @@ -53,8 +53,8 @@ return { { 'w', group = '[W]indow' }, { 'y', group = '[Y]ank' }, { 'S', group = '[S]ession' }, - { 'g', group = 'Git', mode = { 'n', 'v' } }, + { 'g', group = 'Git', mode = { 'n', 'v' } }, { 'q', group = 'Quickfix' }, }, - }, -} + } +end diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 00000000..4663355a --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,151 @@ +{ + "plugins": { + "LuaSnip": { + "rev": "642b0c595e11608b4c18219e93b88d7637af27bc", + "src": "https://github.com/L3MON4D3/LuaSnip", + "version": "2.0.0 - 3.0.0" + }, + "blink.cmp": { + "rev": "50c696b5c3ca359305f8e241e9458b0d2d787540", + "src": "https://github.com/saghen/blink.cmp" + }, + "blink.lib": { + "rev": "5876dd95deeb70aadbe9f1c0b7117a135061cdac", + "src": "https://github.com/saghen/blink.lib" + }, + "conform.nvim": { + "rev": "619363c30309d29ffa631e67c8183f2a72caa373", + "src": "https://github.com/stevearc/conform.nvim" + }, + "fidget.nvim": { + "rev": "82404b196e73a00b1727a91903beef5ddc319d22", + "src": "https://github.com/j-hui/fidget.nvim" + }, + "friendly-snippets": { + "rev": "6cd7280adead7f586db6fccbd15d2cac7e2188b9", + "src": "https://github.com/rafamadriz/friendly-snippets" + }, + "gitsigns.nvim": { + "rev": "2038c666bd9d8a0b7349a0b6ee00dc83104b9ecf", + "src": "https://github.com/lewis6991/gitsigns.nvim" + }, + "guess-indent.nvim": { + "rev": "84a4987ff36798c2fc1169cbaff67960aed9776f", + "src": "https://github.com/NMAC427/guess-indent.nvim" + }, + "harpoon": { + "rev": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3", + "src": "https://github.com/ThePrimeagen/harpoon" + }, + "indent-blankline.nvim": { + "rev": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03", + "src": "https://github.com/lukas-reineke/indent-blankline.nvim" + }, + "markview.nvim": { + "rev": "301e431c7b618235f5447d54465c70934bd33668", + "src": "https://github.com/OXY2DEV/markview.nvim" + }, + "mason-lspconfig.nvim": { + "rev": "21c5b3ebeaa0412e28096bb0701434c51c1fbf76", + "src": "https://github.com/mason-org/mason-lspconfig.nvim" + }, + "mason-nvim-dap.nvim": { + "rev": "9a10e096703966335bd5c46c8c875d5b0690dade", + "src": "https://github.com/jay-babu/mason-nvim-dap.nvim" + }, + "mason-tool-installer.nvim": { + "rev": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc", + "src": "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" + }, + "mason.nvim": { + "rev": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d", + "src": "https://github.com/mason-org/mason.nvim" + }, + "miasma.nvim": { + "rev": "466456f08d1a114c983c0d24e8fc01339e3b0a27", + "src": "https://github.com/OldJobobo/miasma.nvim" + }, + "mini.nvim": { + "rev": "ecb05c524a99490c95a8862eb5cb09b1e629ed42", + "src": "https://github.com/echasnovski/mini.nvim" + }, + "neo-tree.nvim": { + "rev": "83e7a2982fd12b9c3d35bc39dd5877cd91a02a61", + "src": "https://github.com/nvim-neo-tree/neo-tree.nvim", + "version": ">=0.0.0" + }, + "nui.nvim": { + "rev": "de740991c12411b663994b2860f1a4fd0937c130", + "src": "https://github.com/MunifTanjim/nui.nvim" + }, + "nvim-autopairs": { + "rev": "7b9923abad60b903ece7c52940e1321d39eccc79", + "src": "https://github.com/windwp/nvim-autopairs" + }, + "nvim-dap": { + "rev": "9e848e09a697ee95302a3ef2dd43fd6eb709e570", + "src": "https://github.com/mfussenegger/nvim-dap" + }, + "nvim-dap-go": { + "rev": "b4421153ead5d726603b02743ea40cf26a51ed5f", + "src": "https://github.com/leoluz/nvim-dap-go" + }, + "nvim-dap-ui": { + "rev": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49", + "src": "https://github.com/rcarriga/nvim-dap-ui" + }, + "nvim-lint": { + "rev": "01c9842c089069ab497430159312b2c8868a4590", + "src": "https://github.com/mfussenegger/nvim-lint" + }, + "nvim-lspconfig": { + "rev": "bfcc0171a43f22afa61d927ffe9fcb6cb85dc99e", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-nio": { + "rev": "21f5324bfac14e22ba26553caf69ec76ae8a7662", + "src": "https://github.com/nvim-neotest/nvim-nio" + }, + "nvim-treesitter": { + "rev": "4916d6592ede8c07973490d9322f187e07dfefac", + "src": "https://github.com/nvim-treesitter/nvim-treesitter", + "version": "'main'" + }, + "oklch-color-picker.nvim": { + "rev": "9b5db80d5f6af8fbc31bad29f69ad76f63154944", + "src": "https://github.com/eero-lehtinen/oklch-color-picker.nvim" + }, + "plenary.nvim": { + "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "supermaven-nvim": { + "rev": "07d20fce48a5629686aefb0a7cd4b25e33947d50", + "src": "https://github.com/supermaven-inc/supermaven-nvim" + }, + "telescope-fzf-native.nvim": { + "rev": "b25b749b9db64d375d782094e2b9dce53ad53a40", + "src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + "telescope-ui-select.nvim": { + "rev": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2", + "src": "https://github.com/nvim-telescope/telescope-ui-select.nvim" + }, + "telescope.nvim": { + "rev": "9377230aa5305d9e9aca4ed8dadf1070fb4aa9fc", + "src": "https://github.com/nvim-telescope/telescope.nvim" + }, + "trouble.nvim": { + "rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a", + "src": "https://github.com/folke/trouble.nvim" + }, + "vim-tmux-navigator": { + "rev": "e41c431a0c7b7388ae7ba341f01a0d217eb3a432", + "src": "https://github.com/christoomey/vim-tmux-navigator" + }, + "which-key.nvim": { + "rev": "3aab2147e74890957785941f0c1ad87d0a44c15a", + "src": "https://github.com/folke/which-key.nvim" + } + } +}