From 4165338ac45920c12e25b370a0e8115b5c607a72 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Sun, 3 Mar 2024 23:35:06 -1000 Subject: [PATCH 01/22] nvim config --- init.lua | 5 +- lua/custom/plugins/gruvbox-material.lua | 134 ++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 lua/custom/plugins/gruvbox-material.lua diff --git a/init.lua b/init.lua index 292ec0779a9..c69576b0c98 100644 --- a/init.lua +++ b/init.lua @@ -233,6 +233,7 @@ require('lazy').setup { -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, + 'sainnhe/gruvbox-material', -- Here is a more advanced example where we pass configuration -- options to `gitsigns.nvim`. This is equivalent to the following lua: @@ -726,7 +727,7 @@ require('lazy').setup { priority = 1000, -- make sure to load this before all the other start plugins config = function() -- Load the colorscheme here - vim.cmd.colorscheme 'tokyonight-night' + vim.cmd.colorscheme 'gruvbox-material' -- You can configure highlights by doing something like vim.cmd.hi 'Comment gui=none' @@ -819,3 +820,5 @@ require('lazy').setup { -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('x', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) diff --git a/lua/custom/plugins/gruvbox-material.lua b/lua/custom/plugins/gruvbox-material.lua new file mode 100644 index 00000000000..9ba37afb002 --- /dev/null +++ b/lua/custom/plugins/gruvbox-material.lua @@ -0,0 +1,134 @@ +-- ============================================================================= +-- URL: https://github.com/sainnhe/gruvbox-material +-- Filename: lua/lualine/themes/gruvbox-material.lua +-- Author: sainnhe +-- Email: i@sainnhe.dev +-- License: MIT License +-- ============================================================================= + +local configuration = vim.fn['gruvbox_material#get_configuration']() +local palette = vim.fn['gruvbox_material#get_palette'](configuration.background, configuration.foreground, configuration.colors_override) + +if configuration.transparent_background == 2 then + palette.bg_statusline1 = palette.none + palette.bg_statusline2 = palette.none +end + +local theme +if configuration.statusline_style == 'default' then + theme = { + normal = { + a = {bg = palette.grey2[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + insert = { + a = {bg = palette.bg_green[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + visual = { + a = {bg = palette.bg_red[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + replace = { + a = {bg = palette.bg_yellow[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + command = { + a = {bg = palette.blue[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + terminal = { + a = {bg = palette.purple[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + inactive = { + a = {bg = palette.bg_statusline1[1], fg = palette.grey2[1]}, + b = {bg = palette.bg_statusline1[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.grey2[1]} + } + } +elseif configuration.statusline_style == 'mix' then + theme = { + normal = { + a = {bg = palette.grey2[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} + }, + insert = { + a = {bg = palette.bg_green[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + visual = { + a = {bg = palette.bg_red[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + replace = { + a = {bg = palette.bg_yellow[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + command = { + a = {bg = palette.blue[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + terminal = { + a = {bg = palette.purple[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + inactive = { + a = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, + b = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} + } + } +else + theme = { + normal = { + a = {bg = palette.grey2[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} + }, + insert = { + a = {bg = palette.blue[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} + }, + visual = { + a = {bg = palette.orange[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.grey0[1], fg = palette.bg0[1]} + }, + replace = { + a = {bg = palette.aqua[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} + }, + command = { + a = {bg = palette.green[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} + }, + terminal = { + a = {bg = palette.purple[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} + }, + inactive = { + a = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, + b = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} + } + } +end + +return theme From afed39f595301147188dac2c5453bce8515d5325 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto <66350813+RiverMatsumoto@users.noreply.github.com> Date: Sun, 3 Mar 2024 23:36:26 -1000 Subject: [PATCH 02/22] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b6d19f49787..399f580d038 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # kickstart.nvim +# install: +`https://github.com/RiverMatsumoto/kickstart.nvim.git` + ## Introduction A starting point for Neovim that is: From de4998bc4628a3b663703fd274cb88d65c2e236c Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Sun, 3 Mar 2024 23:37:23 -1000 Subject: [PATCH 03/22] nvim --- .github/ISSUE_TEMPLATE/bug_report.md | 28 - .github/workflows/stylua.yml | 21 - .gitignore | 14 +- .stylua.toml | 12 +- LICENSE.md | 38 +- README.md | 436 +++--- doc/kickstart.txt | 48 +- doc/tags | 6 +- init.lua | 1645 ++++++++++++----------- lua/custom/plugins/autopairs.lua | 12 + lua/custom/plugins/filetree.lua | 15 + lua/custom/plugins/gruvbox-material.lua | 134 ++ lua/custom/plugins/init.lua | 10 +- lua/kickstart/health.lua | 104 +- lua/kickstart/plugins/debug.lua | 174 +-- lua/kickstart/plugins/indent_line.lua | 18 +- 16 files changed, 1415 insertions(+), 1300 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/workflows/stylua.yml create mode 100644 lua/custom/plugins/autopairs.lua create mode 100644 lua/custom/plugins/filetree.lua create mode 100644 lua/custom/plugins/gruvbox-material.lua diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 2ad4d31ddb0..00000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - - - -## Describe the bug - - -## To Reproduce - -1. ... - -## Desktop - -- OS: -- Terminal: - -## Neovim Version - - -``` -``` diff --git a/.github/workflows/stylua.yml b/.github/workflows/stylua.yml deleted file mode 100644 index 75db6c3355b..00000000000 --- a/.github/workflows/stylua.yml +++ /dev/null @@ -1,21 +0,0 @@ -# Check Lua Formatting -name: Check Lua Formatting -on: pull_request_target - -jobs: - stylua-check: - if: github.repository == 'nvim-lua/kickstart.nvim' - name: Stylua Check - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - - name: Stylua Check - uses: JohnnyMorganz/stylua-action@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: latest - args: --check . - diff --git a/.gitignore b/.gitignore index 005b535b606..dff024d3542 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ -tags -test.sh -.luarc.json -nvim - -spell/ -lazy-lock.json +tags +test.sh +.luarc.json +nvim + +spell/ +lazy-lock.json diff --git a/.stylua.toml b/.stylua.toml index 139e9397d90..77e5d9cee63 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -1,6 +1,6 @@ -column_width = 160 -line_endings = "Unix" -indent_type = "Spaces" -indent_width = 2 -quote_style = "AutoPreferSingle" -call_parentheses = "None" +column_width = 160 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferSingle" +call_parentheses = "None" diff --git a/LICENSE.md b/LICENSE.md index 9cf106272ac..9dccfa49cba 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,19 +1,19 @@ -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index b6d19f49787..a50b2e9bc8d 100644 --- a/README.md +++ b/README.md @@ -1,218 +1,218 @@ -# kickstart.nvim - -## Introduction - -A starting point for Neovim that is: - -* Small -* Single-file -* Completely Documented - -**NOT** a Neovim distribution, but instead a starting point for your configuration. - -## Installation - -### Install Neovim - -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. - -### Install External Dependencies - -> **NOTE** -> [Backup](#FAQ) your previous configuration (if any exists) - -External Requirements: -- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) -- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) -- Language Setup: - - If want to write Typescript, you need `npm` - - If want to write Golang, you will need `go` - - etc. - -> **NOTE** -> See [Windows Installation](#Windows-Installation) to double check any additional Windows notes - -Neovim's configurations are located under the following paths, depending on your OS: - -| OS | PATH | -| :- | :--- | -| Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` | -| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` | - -### Install Kickstart - -Clone kickstart.nvim: - -
Linux and Mac - -```sh -git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim -``` - -
- -
Windows - -If you're using `cmd.exe`: - -``` -git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ -``` - -If you're using `powershell.exe` - -``` -git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ -``` - -
- -### Post Installation - -Start Neovim - -```sh -nvim -``` - -That's it! Lazy will install all the plugins you have. Use `:Lazy` to view -current plugin status. - -Read through the `init.lua` file in your configuration folder for more -information about extending and exploring Neovim. - -### Getting Started - -See [Effective Neovim: Instant IDE](https://youtu.be/stqUbv-5u2s), covering the -previous version. Note: The install via init.lua is outdated, please follow the -install instructions in this file instead. An updated video is coming soon. - -### Recommended Steps - -[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo -(so that you have your own copy that you can modify) and then installing you -can install to your machine using the methods above. - -> **NOTE** -> Your fork's url will be something like this: `https://github.com//kickstart.nvim.git` - -#### Examples of adding popularly requested plugins - -NOTE: You'll need to uncomment the line in the init.lua that turns on loading custom plugins. - -
- Adding autopairs - -This will automatically install [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs) and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). - -In the file: `lua/custom/plugins/autopairs.lua`, add: - -```lua --- File: lua/custom/plugins/autopairs.lua - -return { - "windwp/nvim-autopairs", - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require("nvim-autopairs").setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require('nvim-autopairs.completion.cmp') - local cmp = require('cmp') - cmp.event:on( - 'confirm_done', - cmp_autopairs.on_confirm_done() - ) - end, -} -``` - -
-
- Adding a file tree plugin - -This will install the tree plugin and add the command `:Neotree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. - -In the file: `lua/custom/plugins/filetree.lua`, add: - -```lua --- Unless you are still migrating, remove the deprecated commands from v1.x -vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) - -return { - "nvim-neo-tree/neo-tree.nvim", - version = "*", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - }, - config = function () - require('neo-tree').setup {} - end, -} -``` - -
- -### FAQ - -* What should I do if I already have a pre-existing neovim configuration? - * You should back it up, then delete all files associated with it. - * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` -* Can I keep my existing configuration in parallel to kickstart? - * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` to maintain multiple configurations. For example you can install the kickstart configuration in `~/.config/nvim-kickstart` and create an alias: - ``` - alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim' - ``` - When you run Neovim using `nvim-kickstart` alias it will use the alternative config directory and the matching local directory `~/.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://github.com/folke/lazy.nvim#-uninstalling) information -* 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 `git clone` as a basis for their own. - As you progress in learning Neovim and Lua, you might consider splitting `init.lua` - into smaller parts. A fork of kickstart that does this while maintaining the exact - same functionality is available here: - * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) - * Discussions on this topic can be found here: - * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) - * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) - -### Windows Installation - -Installation may require installing build tools, and updating the run command for `telescope-fzf-native` - -See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) - -This requires: - -- Install CMake, and the Microsoft C++ Build Tools on Windows - -```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' } -``` - -Alternatively one can install gcc and make which don't require changing the config, -the easiest way is to use choco: - -1. install [chocolatey](https://chocolatey.org/install) -either follow the instructions on the page or use winget, -run in cmd as **admin**: -``` -winget install --accept-source-agreements chocolatey.chocolatey -``` - -2. install all requirements using choco, exit previous cmd and -open a new one so that choco path is set, run in cmd as **admin**: -``` -choco install -y neovim git ripgrep wget fd unzip gzip mingw make -``` - -Then continue with the [Install Kickstart](#Install-Kickstart) step. - - +# kickstart.nvim + +## Introduction + +A starting point for Neovim that is: + +* Small +* Single-file +* Completely Documented + +**NOT** a Neovim distribution, but instead a starting point for your configuration. + +## Installation + +### Install Neovim + +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. + +### Install External Dependencies + +> **NOTE** +> [Backup](#FAQ) your previous configuration (if any exists) + +External Requirements: +- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) +- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) +- Language Setup: + - If want to write Typescript, you need `npm` + - If want to write Golang, you will need `go` + - etc. + +> **NOTE** +> See [Windows Installation](#Windows-Installation) to double check any additional Windows notes + +Neovim's configurations are located under the following paths, depending on your OS: + +| OS | PATH | +| :- | :--- | +| Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | +| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` | +| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` | + +### Install Kickstart + +Clone kickstart.nvim: + +
Linux and Mac + +```sh +git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim +``` + +
+ +
Windows + +If you're using `cmd.exe`: + +``` +git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ +``` + +If you're using `powershell.exe` + +``` +git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ +``` + +
+ +### Post Installation + +Start Neovim + +```sh +nvim +``` + +That's it! Lazy will install all the plugins you have. Use `:Lazy` to view +current plugin status. + +Read through the `init.lua` file in your configuration folder for more +information about extending and exploring Neovim. + +### Getting Started + +See [Effective Neovim: Instant IDE](https://youtu.be/stqUbv-5u2s), covering the +previous version. Note: The install via init.lua is outdated, please follow the +install instructions in this file instead. An updated video is coming soon. + +### Recommended Steps + +[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo +(so that you have your own copy that you can modify) and then installing you +can install to your machine using the methods above. + +> **NOTE** +> Your fork's url will be something like this: `https://github.com//kickstart.nvim.git` + +#### Examples of adding popularly requested plugins + +NOTE: You'll need to uncomment the line in the init.lua that turns on loading custom plugins. + +
+ Adding autopairs + +This will automatically install [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs) and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). + +In the file: `lua/custom/plugins/autopairs.lua`, add: + +```lua +-- File: lua/custom/plugins/autopairs.lua + +return { + "windwp/nvim-autopairs", + -- Optional dependency + dependencies = { 'hrsh7th/nvim-cmp' }, + config = function() + require("nvim-autopairs").setup {} + -- If you want to automatically add `(` after selecting a function or method + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + local cmp = require('cmp') + cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() + ) + end, +} +``` + +
+
+ Adding a file tree plugin + +This will install the tree plugin and add the command `:Neotree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. + +In the file: `lua/custom/plugins/filetree.lua`, add: + +```lua +-- Unless you are still migrating, remove the deprecated commands from v1.x +vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + +return { + "nvim-neo-tree/neo-tree.nvim", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function () + require('neo-tree').setup {} + end, +} +``` + +
+ +### FAQ + +* What should I do if I already have a pre-existing neovim configuration? + * You should back it up, then delete all files associated with it. + * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` +* Can I keep my existing configuration in parallel to kickstart? + * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` to maintain multiple configurations. For example you can install the kickstart configuration in `~/.config/nvim-kickstart` and create an alias: + ``` + alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim' + ``` + When you run Neovim using `nvim-kickstart` alias it will use the alternative config directory and the matching local directory `~/.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://github.com/folke/lazy.nvim#-uninstalling) information +* 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 `git clone` as a basis for their own. + As you progress in learning Neovim and Lua, you might consider splitting `init.lua` + into smaller parts. A fork of kickstart that does this while maintaining the exact + same functionality is available here: + * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) + * Discussions on this topic can be found here: + * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) + * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) + +### Windows Installation + +Installation may require installing build tools, and updating the run command for `telescope-fzf-native` + +See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) + +This requires: + +- Install CMake, and the Microsoft C++ Build Tools on Windows + +```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' } +``` + +Alternatively one can install gcc and make which don't require changing the config, +the easiest way is to use choco: + +1. install [chocolatey](https://chocolatey.org/install) +either follow the instructions on the page or use winget, +run in cmd as **admin**: +``` +winget install --accept-source-agreements chocolatey.chocolatey +``` + +2. install all requirements using choco, exit previous cmd and +open a new one so that choco path is set, run in cmd as **admin**: +``` +choco install -y neovim git ripgrep wget fd unzip gzip mingw make +``` + +Then continue with the [Install Kickstart](#Install-Kickstart) step. + + diff --git a/doc/kickstart.txt b/doc/kickstart.txt index cb87ac3f1de..b12a7d51eb5 100644 --- a/doc/kickstart.txt +++ b/doc/kickstart.txt @@ -1,24 +1,24 @@ -================================================================================ -INTRODUCTION *kickstart.nvim* - -Kickstart.nvim is a project to help you get started on your neovim journey. - - *kickstart-is-not* -It is not: -- Complete framework for every plugin under the sun -- Place to add every plugin that could ever be useful - - *kickstart-is* -It is: -- Somewhere that has a good start for the most common "IDE" type features: - - autocompletion - - goto-definition - - find references - - fuzzy finding - - and hinting at what more can be done :) -- A place to _kickstart_ your journey. - - You should fork this project and use/modify it so that it matches your - style and preferences. If you don't want to do that, there are probably - other projects that would fit much better for you (and that's great!)! - - vim:tw=78:ts=8:ft=help:norl: +================================================================================ +INTRODUCTION *kickstart.nvim* + +Kickstart.nvim is a project to help you get started on your neovim journey. + + *kickstart-is-not* +It is not: +- Complete framework for every plugin under the sun +- Place to add every plugin that could ever be useful + + *kickstart-is* +It is: +- Somewhere that has a good start for the most common "IDE" type features: + - autocompletion + - goto-definition + - find references + - fuzzy finding + - and hinting at what more can be done :) +- A place to _kickstart_ your journey. + - You should fork this project and use/modify it so that it matches your + style and preferences. If you don't want to do that, there are probably + other projects that would fit much better for you (and that's great!)! + + vim:tw=78:ts=8:ft=help:norl: diff --git a/doc/tags b/doc/tags index 687ae7721d9..8b630230dfc 100644 --- a/doc/tags +++ b/doc/tags @@ -1,3 +1,3 @@ -kickstart-is kickstart.txt /*kickstart-is* -kickstart-is-not kickstart.txt /*kickstart-is-not* -kickstart.nvim kickstart.txt /*kickstart.nvim* +kickstart-is kickstart.txt /*kickstart-is* +kickstart-is-not kickstart.txt /*kickstart-is-not* +kickstart.nvim kickstart.txt /*kickstart.nvim* diff --git a/init.lua b/init.lua index 292ec0779a9..1bc6c59b7d4 100644 --- a/init.lua +++ b/init.lua @@ -1,821 +1,824 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know how the Neovim basics, you can skip this step) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not sure exactly what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or neovim features used in kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your nvim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) ---]] - --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' - --- [[ Setting options ]] --- See `:help vim.opt` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` - --- Make line numbers default -vim.opt.number = true --- You can also add relative line numbers, for help with jumping. --- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true - --- Enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = 'a' - --- Don't show the mode, since it's already in status line -vim.opt.showmode = false - --- Sync clipboard between OS and Neovim. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` -vim.opt.clipboard = 'unnamedplus' - --- Enable break indent -vim.opt.breakindent = true - --- Save undo history -vim.opt.undofile = true - --- Case-insensitive searching UNLESS \C or capital in search -vim.opt.ignorecase = true -vim.opt.smartcase = true - --- Keep signcolumn on by default -vim.opt.signcolumn = 'yes' - --- Decrease update time -vim.opt.updatetime = 250 -vim.opt.timeoutlen = 300 - --- Configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = true - --- Sets how neovim will display certain whitespace in the editor. --- See `:help 'list'` --- and `:help 'listchars'` -vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } - --- Preview substitutions live, as you type! -vim.opt.inccommand = 'split' - --- Show which line your cursor is on -vim.opt.cursorline = true - --- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 - --- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` - --- Set highlight on search, but clear on pressing in normal mode -vim.opt.hlsearch = true -vim.keymap.set('n', '', 'nohlsearch') - --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) - --- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier --- for people to discover. Otherwise, you normally need to press , which --- is not what someone will guess without a bit more experience. --- --- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping --- or just use to exit terminal mode -vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - --- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') - --- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows --- --- See `:help wincmd` for a list of all window commands -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) - --- [[ Install `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.loop.fs_stat(lazypath) then - local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } -end ---@diagnostic disable-next-line: undefined-field -vim.opt.rtp:prepend(lazypath) - --- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- --- To update plugins, you can run --- :Lazy update --- --- NOTE: Here is where you install your plugins. -require('lazy').setup { - -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). - 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically - - -- NOTE: Plugins can also be added by using a table, - -- with the first argument being the link and the following - -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to force a plugin to be loaded. - -- - -- This is equivalent to: - -- require('Comment').setup({}) - - -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, - - -- Here is a more advanced example where we pass configuration - -- options to `gitsigns.nvim`. This is equivalent to the following lua: - -- require('gitsigns').setup({ ... }) - -- - -- See `:help gitsigns` to understand what the configuration keys do - { -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, - }, - - -- NOTE: Plugins can also be configured to run lua code when they are loaded. - -- - -- This is often very useful to both group configuration, as well as handle - -- lazy loading plugins that don't need to be loaded immediately at startup. - -- - -- For example, in the following configuration, we use: - -- event = 'VimEnter' - -- - -- which loads which-key before all the UI elements are loaded. Events can be - -- normal autocommands events (`:help autocmd-events`). - -- - -- Then, because we use the `config` key, the configuration only runs - -- after the plugin has been loaded: - -- config = function() ... end - - { -- Useful plugin to show you pending keybinds. - 'folke/which-key.nvim', - event = 'VimEnter', -- Sets the loading event to 'VimEnter' - config = function() -- This is the function that runs, AFTER loading - require('which-key').setup() - - -- Document existing key chains - require('which-key').register { - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, - } - end, - }, - - -- NOTE: Plugins can specify dependencies. - -- - -- The dependencies are proper plugin specifications as well - anything - -- you do for a plugin at the top level, you can do for a dependency. - -- - -- Use the `dependencies` key to specify the dependencies of a particular plugin - - { -- Fuzzy Finder (files, lsp, etc) - 'nvim-telescope/telescope.nvim', - event = 'VimEnter', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for install instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires special font. - -- If you already have a Nerd Font, or terminal set up with fallback fonts - -- you can enable this - -- { 'nvim-tree/nvim-web-devicons' } - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of help_tags options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable telescope extensions, if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- Also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[S]earch [/] in Open Files' }) - - -- Shortcut for searching your neovim configuration files - vim.keymap.set('n', 'sn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) - end, - }, - - { -- LSP Configuration & Plugins - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs and related tools to stdpath for neovim - 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP. - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, - }, - config = function() - -- Brief Aside: **What is LSP?** - -- - -- LSP is an acronym you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc) - vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - - -- Find references for the word under your cursor. - map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - - -- Fuzzy find all the symbols in your current workspace - -- Similar to document symbols, except searches over your whole project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- Rename the variable under your cursor - -- Most Language Servers support renaming across files, etc. - map('rn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - - -- Opens a popup that displays documentation about the word under your cursor - -- See `:help K` for why this keymap - map('K', vim.lsp.buf.hover, 'Hover Documentation') - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header - map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.server_capabilities.documentHighlightProvider then - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - callback = vim.lsp.buf.clear_references, - }) - end - end, - }) - - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP Specification. - -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - - -- Enable the following language servers - -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. - -- - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, - -- - - lua_ls = { - -- cmd = {...}, - -- filetypes { ...}, - -- capabilities = {}, - settings = { - Lua = { - runtime = { version = 'LuaJIT' }, - workspace = { - checkThirdParty = false, - -- Tells lua_ls where to find all the Lua files that you have loaded - -- for your neovim configuration. - library = { - '${3rd}/luv/library', - unpack(vim.api.nvim_get_runtime_file('', true)), - }, - -- If lua_ls is really slow on your computer, you can try this instead: - -- library = { vim.env.VIMRUNTIME }, - }, - completion = { - callSnippet = 'Replace', - }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, - }, - }, - }, - } - - -- Ensure the servers and tools above are installed - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu - require('mason').setup() - - -- You can add other tools here that you want Mason to install - -- for you, so that they are available from within Neovim. - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'stylua', -- Used to format lua code - }) - require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - require('mason-lspconfig').setup { - handlers = { - function(server_name) - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for tsserver) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } - end, - }, - - { -- Autoformat - 'stevearc/conform.nvim', - opts = { - notify_on_error = false, - format_on_save = { - timeout_ms = 500, - lsp_fallback = true, - }, - formatters_by_ft = { - lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use a sub-list to tell conform to run *until* a formatter - -- is found. - -- javascript = { { "prettierd", "prettier" } }, - }, - }, - }, - - { -- Autocompletion - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - 'L3MON4D3/LuaSnip', - build = (function() - -- Build Step is needed for regex support in snippets - -- This step is not supported in many windows environments - -- Remove the below condition to re-enable on windows - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - }, - 'saadparwaiz1/cmp_luasnip', - - -- Adds other completion capabilities. - -- nvim-cmp does not ship with all sources by default. They are split - -- into multiple repos for maintenance purposes. - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-path', - - -- If you want to add a bunch of pre-configured snippets, - -- you can use this plugin to help you. It even has snippets - -- for various frameworks/libraries/etc. but you will have to - -- set up the ones that are useful for you. - -- 'rafamadriz/friendly-snippets', - }, - config = function() - -- See `:help cmp` - local cmp = require 'cmp' - local luasnip = require 'luasnip' - luasnip.config.setup {} - - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = 'menu,menuone,noinsert' }, - - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = cmp.mapping.preset.insert { - -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), - - -- Accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, - - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [''] = cmp.mapping.complete {}, - - -- Think of as moving to the right of your snippet expansion. - -- So if you have a snippet that's like: - -- function $name($args) - -- $body - -- end - -- - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [''] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - }, - } - end, - }, - - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme` - 'folke/tokyonight.nvim', - lazy = false, -- make sure we load this during startup if it is your main colorscheme - priority = 1000, -- make sure to load this before all the other start plugins - config = function() - -- Load the colorscheme here - vim.cmd.colorscheme 'tokyonight-night' - - -- You can configure highlights by doing something like - vim.cmd.hi 'Comment gui=none' - end, - }, - - -- Highlight todo, notes, etc in comments - { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - - { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [']quote - -- - ci' - [C]hange [I]nside [']quote - require('mini.ai').setup { n_lines = 500 } - - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() - - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - statusline.setup() - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we disable the section for - -- cursor information because line numbers are already enabled - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '' - end - - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim - end, - }, - - { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - config = function() - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { enable = true }, - indent = { enable = true }, - } - - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects - end, - }, - - -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the - -- init.lua. If you want these files, they are in the repository, so you can just download them and - -- put them in the right spots if you want. - - -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for kickstart - -- - -- Here are some example plugins that I've included in the kickstart repository. - -- Uncomment any of the lines below to enable them (you will need to restart nvim). - -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` - -- This is the easiest way to modularize your config. - -- - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, -} - --- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et +--[[ + +===================================================================== +==================== READ THIS BEFORE CONTINUING ==================== +===================================================================== +======== .-----. ======== +======== .----------------------. | === | ======== +======== |.-""""""""""""""""""-.| |-----| ======== +======== || || | === | ======== +======== || KICKSTART.NVIM || |-----| ======== +======== || || | === | ======== +======== || || |-----| ======== +======== ||:Tutor || |:::::| ======== +======== |'-..................-'| |____o| ======== +======== `"")----------------(""` ___________ ======== +======== /::::::::::| |::::::::::\ \ no mouse \ ======== +======== /:::========| |==hjkl==:::\ \ required \ ======== +======== '""""""""""""' '""""""""""""' '""""""""""' ======== +======== ======== +===================================================================== +===================================================================== + +What is Kickstart? + + Kickstart.nvim is *not* a distribution. + + Kickstart.nvim is a starting point for your own configuration. + The goal is that you can read every line of code, top-to-bottom, understand + what your configuration is doing, and modify it to suit your needs. + + Once you've done that, you can start exploring, configuring and tinkering to + make Neovim your own! That might mean leaving kickstart just the way it is for a while + or immediately breaking it into modular pieces. It's up to you! + + If you don't know anything about Lua, I recommend taking some time to read through + a guide. One possible example which will only take 10-15 minutes: + - https://learnxinyminutes.com/docs/lua/ + + After understanding a bit more about Lua, you can use `:help lua-guide` as a + reference for how Neovim integrates Lua. + - :help lua-guide + - (or HTML version): https://neovim.io/doc/user/lua-guide.html + +Kickstart Guide: + + TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. + + If you don't know what this means, type the following: + - + - : + - Tutor + - + + (If you already know how the Neovim basics, you can skip this step) + + Once you've completed that, you can continue working through **AND READING** the rest + of the kickstart init.lua + + Next, run AND READ `:help`. + This will open up a help window with some basic information + about reading, navigating and searching the builtin help documentation. + + This should be the first place you go to look when you're stuck or confused + with something. It's one of my favorite neovim features. + + MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, + which is very useful when you're not sure exactly what you're looking for. + + I have left several `:help X` comments throughout the init.lua + These are hints about where to find more information about the relevant settings, + plugins or neovim features used in kickstart. + + NOTE: Look for lines like this + + Throughout the file. These are for you, the reader, to help understand what is happening. + Feel free to delete them once you know what you're doing, but they should serve as a guide + for when you are first encountering a few different constructs in your nvim config. + +If you experience any errors while trying to install kickstart, run `:checkhealth` for more info + +I hope you enjoy your Neovim journey, +- TJ + +P.S. You can delete this when you're done too. It's your config now! :) +--]] + +-- Set as the leader key +-- See `:help mapleader` +-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- [[ Setting options ]] +-- See `:help vim.opt` +-- NOTE: You can change these options as you wish! +-- For more options, you can see `:help option-list` + +-- Make line numbers default +vim.opt.number = true +-- You can also add relative line numbers, for help with jumping. +-- Experiment for yourself to see if you like it! +-- vim.opt.relativenumber = true + +-- Enable mouse mode, can be useful for resizing splits for example! +vim.opt.mouse = 'a' + +-- Don't show the mode, since it's already in status line +vim.opt.showmode = false + +-- Sync clipboard between OS and Neovim. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.opt.clipboard = 'unnamedplus' + +-- Enable break indent +vim.opt.breakindent = true + +-- Save undo history +vim.opt.undofile = true + +-- Case-insensitive searching UNLESS \C or capital in search +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- Keep signcolumn on by default +vim.opt.signcolumn = 'yes' + +-- Decrease update time +vim.opt.updatetime = 250 +vim.opt.timeoutlen = 300 + +-- Configure how new splits should be opened +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- Sets how neovim will display certain whitespace in the editor. +-- See `:help 'list'` +-- and `:help 'listchars'` +vim.opt.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + +-- Preview substitutions live, as you type! +vim.opt.inccommand = 'split' + +-- Show which line your cursor is on +vim.opt.cursorline = true + +-- Minimal number of screen lines to keep above and below the cursor. +vim.opt.scrolloff = 10 + +-- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` + +-- Set highlight on search, but clear on pressing in normal mode +vim.opt.hlsearch = true +vim.keymap.set('n', '', 'nohlsearch') + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) + +-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier +-- for people to discover. Otherwise, you normally need to press , which +-- is not what someone will guess without a bit more experience. +-- +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping +-- or just use to exit terminal mode +vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) + +-- TIP: Disable arrow keys in normal mode +-- vim.keymap.set('n', '', 'echo "Use h to move!!"') +-- vim.keymap.set('n', '', 'echo "Use l to move!!"') +-- vim.keymap.set('n', '', 'echo "Use k to move!!"') +-- vim.keymap.set('n', '', 'echo "Use j to move!!"') + +-- Keybinds to make split navigation easier. +-- Use CTRL+ to switch between windows +-- +-- See `:help wincmd` for a list of all window commands +vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) + +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- [[ Install `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.loop.fs_stat(lazypath) then + local lazyrepo = 'https://github.com/folke/lazy.nvim.git' + vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } +end ---@diagnostic disable-next-line: undefined-field +vim.opt.rtp:prepend(lazypath) + +-- [[ Configure and install plugins ]] +-- +-- To check the current status of your plugins, run +-- :Lazy +-- +-- You can press `?` in this menu for help. Use `:q` to close the window +-- +-- To update plugins, you can run +-- :Lazy update +-- +-- NOTE: Here is where you install your plugins. +require('lazy').setup { + -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). + 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + + -- NOTE: Plugins can also be added by using a table, + -- with the first argument being the link and the following + -- keys can be used to configure plugin behavior/loading/etc. + -- + -- Use `opts = {}` to force a plugin to be loaded. + -- + -- This is equivalent to: + -- require('Comment').setup({}) + + -- "gc" to comment visual regions/lines + { 'numToStr/Comment.nvim', opts = {} }, + 'sainnhe/gruvbox-material', + + -- Here is a more advanced example where we pass configuration + -- options to `gitsigns.nvim`. This is equivalent to the following lua: + -- require('gitsigns').setup({ ... }) + -- + -- See `:help gitsigns` to understand what the configuration keys do + { -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + }, + }, + + -- NOTE: Plugins can also be configured to run lua code when they are loaded. + -- + -- This is often very useful to both group configuration, as well as handle + -- lazy loading plugins that don't need to be loaded immediately at startup. + -- + -- For example, in the following configuration, we use: + -- event = 'VimEnter' + -- + -- which loads which-key before all the UI elements are loaded. Events can be + -- normal autocommands events (`:help autocmd-events`). + -- + -- Then, because we use the `config` key, the configuration only runs + -- after the plugin has been loaded: + -- config = function() ... end + + { -- Useful plugin to show you pending keybinds. + 'folke/which-key.nvim', + event = 'VimEnter', -- Sets the loading event to 'VimEnter' + config = function() -- This is the function that runs, AFTER loading + require('which-key').setup() + + -- Document existing key chains + require('which-key').register { + ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, + ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, + ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, + ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, + } + end, + }, + + -- NOTE: Plugins can specify dependencies. + -- + -- The dependencies are proper plugin specifications as well - anything + -- you do for a plugin at the top level, you can do for a dependency. + -- + -- Use the `dependencies` key to specify the dependencies of a particular plugin + + { -- Fuzzy Finder (files, lsp, etc) + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { -- If encountering errors, see telescope-fzf-native README for install instructions + 'nvim-telescope/telescope-fzf-native.nvim', + + -- `build` is used to run some command when the plugin is installed/updated. + -- This is only run then, not every time Neovim starts up. + build = 'make', + + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + + -- Useful for getting pretty icons, but requires special font. + -- If you already have a Nerd Font, or terminal set up with fallback fonts + -- you can enable this + -- { 'nvim-tree/nvim-web-devicons' } + }, + config = function() + -- Telescope is a fuzzy finder that comes with a lot of different things that + -- it can fuzzy find! It's more than just a "file finder", it can search + -- many different aspects of Neovim, your workspace, LSP, and more! + -- + -- The easiest way to use telescope, is to start by doing something like: + -- :Telescope help_tags + -- + -- After running this command, a window will open up and you're able to + -- type in the prompt window. You'll see a list of help_tags options and + -- a corresponding preview of the help. + -- + -- Two important keymaps to use while in telescope are: + -- - Insert mode: + -- - Normal mode: ? + -- + -- This opens a window that shows you all of the keymaps for the current + -- telescope picker. This is really useful to discover what Telescope can + -- do as well as how to actually do it! + + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + -- You can put your default mappings / updates / etc. in here + -- All the info you're looking for is in `:help telescope.setup()` + -- + -- defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, + -- pickers = {} + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + -- Enable telescope extensions, if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + + -- Slightly advanced example of overriding default behavior and theme + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- Also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set('n', 's/', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) + + -- Shortcut for searching your neovim configuration files + vim.keymap.set('n', 'sn', function() + builtin.find_files { cwd = vim.fn.stdpath 'config' } + end, { desc = '[S]earch [N]eovim files' }) + end, + }, + + { -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs and related tools to stdpath for neovim + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + + -- Useful status updates for LSP. + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, + }, + config = function() + -- Brief Aside: **What is LSP?** + -- + -- LSP is an acronym you've probably heard, but might not understand what it is. + -- + -- LSP stands for Language Server Protocol. It's a protocol that helps editors + -- and language tooling communicate in a standardized fashion. + -- + -- In general, you have a "server" which is some tool built to understand a particular + -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc). These Language Servers + -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone + -- processes that communicate with some "client" - in this case, Neovim! + -- + -- LSP provides Neovim with features like: + -- - Go to definition + -- - Find references + -- - Autocompletion + -- - Symbol Search + -- - and more! + -- + -- Thus, Language Servers are external tools that must be installed separately from + -- Neovim. This is where `mason` and related plugins come into play. + -- + -- If you're wondering about lsp vs treesitter, you can check out the wonderfully + -- and elegantly composed help section, `:help lsp-vs-treesitter` + + -- This function gets run when an LSP attaches to a particular buffer. + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local map = function(keys, func, desc) + vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + + -- Find references for the word under your cursor. + map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + + -- Fuzzy find all the symbols in your current workspace + -- Similar to document symbols, except searches over your whole project. + map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- Rename the variable under your cursor + -- Most Language Servers support renaming across files, etc. + map('rn', vim.lsp.buf.rename, '[R]e[n]ame') + + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + + -- Opens a popup that displays documentation about the word under your cursor + -- See `:help K` for why this keymap + map('K', vim.lsp.buf.hover, 'Hover Documentation') + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header + map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.server_capabilities.documentHighlightProvider then + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + callback = vim.lsp.buf.clear_references, + }) + end + end, + }) + + -- LSP servers and clients are able to communicate to each other what features they support. + -- By default, Neovim doesn't support everything that is in the LSP Specification. + -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`tsserver`) will work just fine + -- tsserver = {}, + -- + + lua_ls = { + -- cmd = {...}, + -- filetypes { ...}, + -- capabilities = {}, + settings = { + Lua = { + runtime = { version = 'LuaJIT' }, + workspace = { + checkThirdParty = false, + -- Tells lua_ls where to find all the Lua files that you have loaded + -- for your neovim configuration. + library = { + '${3rd}/luv/library', + unpack(vim.api.nvim_get_runtime_file('', true)), + }, + -- If lua_ls is really slow on your computer, you can try this instead: + -- library = { vim.env.VIMRUNTIME }, + }, + completion = { + callSnippet = 'Replace', + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + } + + -- Ensure the servers and tools above are installed + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu + require('mason').setup() + + -- You can add other tools here that you want Mason to install + -- for you, so that they are available from within Neovim. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'stylua', -- Used to format lua code + }) + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + require('mason-lspconfig').setup { + handlers = { + function(server_name) + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for tsserver) + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + } + end, + }, + + { -- Autoformat + 'stevearc/conform.nvim', + opts = { + notify_on_error = false, + format_on_save = { + timeout_ms = 500, + lsp_fallback = true, + }, + formatters_by_ft = { + lua = { 'stylua' }, + -- Conform can also run multiple formatters sequentially + -- python = { "isort", "black" }, + -- + -- You can use a sub-list to tell conform to run *until* a formatter + -- is found. + -- javascript = { { "prettierd", "prettier" } }, + }, + }, + }, + + { -- Autocompletion + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + { + 'L3MON4D3/LuaSnip', + build = (function() + -- Build Step is needed for regex support in snippets + -- This step is not supported in many windows environments + -- Remove the below condition to re-enable on windows + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + }, + 'saadparwaiz1/cmp_luasnip', + + -- Adds other completion capabilities. + -- nvim-cmp does not ship with all sources by default. They are split + -- into multiple repos for maintenance purposes. + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + + -- If you want to add a bunch of pre-configured snippets, + -- you can use this plugin to help you. It even has snippets + -- for various frameworks/libraries/etc. but you will have to + -- set up the ones that are useful for you. + -- 'rafamadriz/friendly-snippets', + }, + config = function() + -- See `:help cmp` + local cmp = require 'cmp' + local luasnip = require 'luasnip' + luasnip.config.setup {} + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = 'menu,menuone,noinsert' }, + + -- For an understanding of why these mappings were + -- chosen, you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! + mapping = cmp.mapping.preset.insert { + -- Select the [n]ext item + [''] = cmp.mapping.select_next_item(), + -- Select the [p]revious item + [''] = cmp.mapping.select_prev_item(), + + -- Accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + [''] = cmp.mapping.confirm { select = true }, + + -- Manually trigger a completion from nvim-cmp. + -- Generally you don't need this, because nvim-cmp will display + -- completions whenever it has completion options available. + [''] = cmp.mapping.complete {}, + + -- Think of as moving to the right of your snippet expansion. + -- So if you have a snippet that's like: + -- function $name($args) + -- $body + -- end + -- + -- will move you to the right of each of the expansion locations. + -- is similar, except moving you backwards. + [''] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + }, + } + end, + }, + + { -- You can easily change to a different colorscheme. + -- Change the name of the colorscheme plugin below, and then + -- change the command in the config to whatever the name of that colorscheme is + -- + -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme` + 'folke/tokyonight.nvim', + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins + config = function() + -- Load the colorscheme here + vim.cmd.colorscheme 'gruvbox-material' + + -- You can configure highlights by doing something like + vim.cmd.hi 'Comment gui=none' + end, + }, + + -- Highlight todo, notes, etc in comments + { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + + { -- Collection of various small independent plugins/modules + 'echasnovski/mini.nvim', + config = function() + -- Better Around/Inside textobjects + -- + -- Examples: + -- - va) - [V]isually select [A]round [)]paren + -- - yinq - [Y]ank [I]nside [N]ext [']quote + -- - ci' - [C]hange [I]nside [']quote + require('mini.ai').setup { n_lines = 500 } + + -- Add/delete/replace surroundings (brackets, quotes, etc.) + -- + -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren + -- - sd' - [S]urround [D]elete [']quotes + -- - sr)' - [S]urround [R]eplace [)] ['] + require('mini.surround').setup() + + -- Simple and easy statusline. + -- You could remove this setup call if you don't like it, + -- and try some other statusline plugin + local statusline = require 'mini.statusline' + statusline.setup() + + -- You can configure sections in the statusline by overriding their + -- default behavior. For example, here we disable the section for + -- cursor information because line numbers are already enabled + ---@diagnostic disable-next-line: duplicate-set-field + statusline.section_location = function() + return '' + end + + -- ... and there is more! + -- Check out: https://github.com/echasnovski/mini.nvim + end, + }, + + { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + config = function() + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + + ---@diagnostic disable-next-line: missing-fields + require('nvim-treesitter.configs').setup { + ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' }, + -- Autoinstall languages that are not installed + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + } + + -- There are additional nvim-treesitter modules that you can use to interact + -- with nvim-treesitter. You should go explore a few and see what interests you: + -- + -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + end, + }, + + -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the + -- init.lua. If you want these files, they are in the repository, so you can just download them and + -- put them in the right spots if you want. + + -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for kickstart + -- + -- Here are some example plugins that I've included in the kickstart repository. + -- Uncomment any of the lines below to enable them (you will need to restart nvim). + -- + -- require 'kickstart.plugins.debug', + -- require 'kickstart.plugins.indent_line', + + -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + -- This is the easiest way to modularize your config. + -- + -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. + -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` + -- { import = 'custom.plugins' }, +} + +-- The line beneath this is called `modeline`. See `:help modeline` +-- vim: ts=2 sts=2 sw=2 et +vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('x', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000000..529c3308ed5 --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,12 @@ +return { + 'windwp/nvim-autopairs', + -- Optional dependency + dependencies = { 'hrsh7th/nvim-cmp' }, + config = function() + require('nvim-autopairs').setup {} + -- If you want to automatically add `(` after selecting a function or method + local cmp_autopairs = require 'nvim-autopairs.completion.cmp' + local cmp = require 'cmp' + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + end, +} diff --git a/lua/custom/plugins/filetree.lua b/lua/custom/plugins/filetree.lua new file mode 100644 index 00000000000..bec15faaf7a --- /dev/null +++ b/lua/custom/plugins/filetree.lua @@ -0,0 +1,15 @@ +-- Unless you are still migrating, remove the deprecated commands from v1.x +vim.cmd [[ let g:neo_tree_remove_legacy_commands = 1 ]] + +return { + 'nvim-neo-tree/neo-tree.nvim', + version = '*', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended + 'MunifTanjim/nui.nvim', + }, + config = function() + require('neo-tree').setup {} + end, +} diff --git a/lua/custom/plugins/gruvbox-material.lua b/lua/custom/plugins/gruvbox-material.lua new file mode 100644 index 00000000000..9ba37afb002 --- /dev/null +++ b/lua/custom/plugins/gruvbox-material.lua @@ -0,0 +1,134 @@ +-- ============================================================================= +-- URL: https://github.com/sainnhe/gruvbox-material +-- Filename: lua/lualine/themes/gruvbox-material.lua +-- Author: sainnhe +-- Email: i@sainnhe.dev +-- License: MIT License +-- ============================================================================= + +local configuration = vim.fn['gruvbox_material#get_configuration']() +local palette = vim.fn['gruvbox_material#get_palette'](configuration.background, configuration.foreground, configuration.colors_override) + +if configuration.transparent_background == 2 then + palette.bg_statusline1 = palette.none + palette.bg_statusline2 = palette.none +end + +local theme +if configuration.statusline_style == 'default' then + theme = { + normal = { + a = {bg = palette.grey2[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + insert = { + a = {bg = palette.bg_green[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + visual = { + a = {bg = palette.bg_red[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + replace = { + a = {bg = palette.bg_yellow[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + command = { + a = {bg = palette.blue[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + terminal = { + a = {bg = palette.purple[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} + }, + inactive = { + a = {bg = palette.bg_statusline1[1], fg = palette.grey2[1]}, + b = {bg = palette.bg_statusline1[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline1[1], fg = palette.grey2[1]} + } + } +elseif configuration.statusline_style == 'mix' then + theme = { + normal = { + a = {bg = palette.grey2[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} + }, + insert = { + a = {bg = palette.bg_green[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + visual = { + a = {bg = palette.bg_red[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + replace = { + a = {bg = palette.bg_yellow[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + command = { + a = {bg = palette.blue[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + terminal = { + a = {bg = palette.purple[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} + }, + inactive = { + a = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, + b = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} + } + } +else + theme = { + normal = { + a = {bg = palette.grey2[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} + }, + insert = { + a = {bg = palette.blue[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} + }, + visual = { + a = {bg = palette.orange[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.grey0[1], fg = palette.bg0[1]} + }, + replace = { + a = {bg = palette.aqua[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} + }, + command = { + a = {bg = palette.green[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} + }, + terminal = { + a = {bg = palette.purple[1], fg = palette.bg0[1], gui = 'bold'}, + b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, + c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} + }, + inactive = { + a = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, + b = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, + c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} + } + } +end + +return theme diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..e4e697d44ca 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -1,5 +1,5 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) --- --- See the kickstart.nvim README for more information -return {} +-- You can add your own plugins here or in other files in this directory! +-- I promise not to create any merge conflicts in this directory :) +-- +-- See the kickstart.nvim README for more information +return {} diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua index 04df77b33e8..44a1dda9e3e 100644 --- a/lua/kickstart/health.lua +++ b/lua/kickstart/health.lua @@ -1,52 +1,52 @@ ---[[ --- --- This file is not required for your own configuration, --- but helps people determine if their system is setup correctly. --- ---]] - -local check_version = function() - local verstr = string.format('%s.%s.%s', vim.version().major, vim.version().minor, vim.version().patch) - if not vim.version.cmp then - vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) - return - end - - if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then - vim.health.ok(string.format("Neovim version is: '%s'", verstr)) - else - vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) - end -end - -local check_external_reqs = function() - -- Basic utils: `git`, `make`, `unzip` - for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do - local is_executable = vim.fn.executable(exe) == 1 - if is_executable then - vim.health.ok(string.format("Found executable: '%s'", exe)) - else - vim.health.warn(string.format("Could not find executable: '%s'", exe)) - end - end - - return true -end - -return { - check = function() - vim.health.start 'kickstart.nvim' - - vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth` - - Fix only warnings for plugins and languages you intend to use. - Mason will give warnings for languages that are not installed. - You do not need to install, unless you want to use those languages!]] - - local uv = vim.uv or vim.loop - vim.health.info('System Information: ' .. vim.inspect(uv.os_uname())) - - check_version() - check_external_reqs() - end, -} +--[[ +-- +-- This file is not required for your own configuration, +-- but helps people determine if their system is setup correctly. +-- +--]] + +local check_version = function() + local verstr = string.format('%s.%s.%s', vim.version().major, vim.version().minor, vim.version().patch) + if not vim.version.cmp then + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) + return + end + + if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then + vim.health.ok(string.format("Neovim version is: '%s'", verstr)) + else + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) + end +end + +local check_external_reqs = function() + -- Basic utils: `git`, `make`, `unzip` + for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do + local is_executable = vim.fn.executable(exe) == 1 + if is_executable then + vim.health.ok(string.format("Found executable: '%s'", exe)) + else + vim.health.warn(string.format("Could not find executable: '%s'", exe)) + end + end + + return true +end + +return { + check = function() + vim.health.start 'kickstart.nvim' + + vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth` + + Fix only warnings for plugins and languages you intend to use. + Mason will give warnings for languages that are not installed. + You do not need to install, unless you want to use those languages!]] + + local uv = vim.uv or vim.loop + vim.health.info('System Information: ' .. vim.inspect(uv.os_uname())) + + check_version() + check_external_reqs() + end, +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 7fc783fabd4..ead74636c2b 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -1,87 +1,87 @@ --- debug.lua --- --- Shows how to use the DAP plugin to debug your code. --- --- Primarily focused on configuring the debugger for Go, but can --- be extended to other languages as well. That's why it's called --- kickstart.nvim and not kitchen-sink.nvim ;) - -return { - -- NOTE: Yes, you can install new plugins here! - 'mfussenegger/nvim-dap', - -- NOTE: And you can specify dependencies as well - dependencies = { - -- Creates a beautiful debugger UI - 'rcarriga/nvim-dap-ui', - - -- Installs the debug adapters for you - 'williamboman/mason.nvim', - 'jay-babu/mason-nvim-dap.nvim', - - -- Add your own debuggers here - 'leoluz/nvim-dap-go', - }, - config = function() - local dap = require 'dap' - local dapui = require 'dapui' - - require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations - automatic_setup = true, - - -- 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', - }, - } - - -- Basic debugging keymaps, feel free to change to your liking! - vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) - vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) - vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) - vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) - vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) - vim.keymap.set('n', 'B', function() - dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, { desc = 'Debug: Set Breakpoint' }) - - -- Dap UI setup - -- For more information, see |:help nvim-dap-ui| - dapui.setup { - -- Set icons to characters that are more likely to work in every terminal. - -- Feel free to remove or use ones that you like more! :) - -- Don't feel like these are good choices. - icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, - controls = { - icons = { - pause = '⏸', - play = '▶', - step_into = '⏎', - step_over = '⏭', - step_out = '⏮', - step_back = 'b', - run_last = '▶▶', - terminate = '⏹', - disconnect = '⏏', - }, - }, - } - - -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) - - dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close - dap.listeners.before.event_exited['dapui_config'] = dapui.close - - -- Install golang specific config - require('dap-go').setup() - end, -} +-- debug.lua +-- +-- Shows how to use the DAP plugin to debug your code. +-- +-- Primarily focused on configuring the debugger for Go, but can +-- be extended to other languages as well. That's why it's called +-- kickstart.nvim and not kitchen-sink.nvim ;) + +return { + -- NOTE: Yes, you can install new plugins here! + 'mfussenegger/nvim-dap', + -- NOTE: And you can specify dependencies as well + dependencies = { + -- Creates a beautiful debugger UI + 'rcarriga/nvim-dap-ui', + + -- Installs the debug adapters for you + 'williamboman/mason.nvim', + 'jay-babu/mason-nvim-dap.nvim', + + -- Add your own debuggers here + 'leoluz/nvim-dap-go', + }, + config = function() + local dap = require 'dap' + local dapui = require 'dapui' + + require('mason-nvim-dap').setup { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_setup = true, + + -- 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', + }, + } + + -- Basic debugging keymaps, feel free to change to your liking! + vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) + vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) + vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) + vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) + vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) + vim.keymap.set('n', 'B', function() + dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, { desc = 'Debug: Set Breakpoint' }) + + -- Dap UI setup + -- For more information, see |:help nvim-dap-ui| + dapui.setup { + -- Set icons to characters that are more likely to work in every terminal. + -- Feel free to remove or use ones that you like more! :) + -- Don't feel like these are good choices. + icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', + }, + }, + } + + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) + + dap.listeners.after.event_initialized['dapui_config'] = dapui.open + dap.listeners.before.event_terminated['dapui_config'] = dapui.close + dap.listeners.before.event_exited['dapui_config'] = dapui.close + + -- Install golang specific config + require('dap-go').setup() + end, +} diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/kickstart/plugins/indent_line.lua index ed7f269399f..8f74053e1f5 100644 --- a/lua/kickstart/plugins/indent_line.lua +++ b/lua/kickstart/plugins/indent_line.lua @@ -1,9 +1,9 @@ -return { - { -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help ibl` - main = 'ibl', - opts = {}, - }, -} +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 = {}, + }, +} From 0ab401530e19ea23ec8a6cc333603ca99d02414c Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Sun, 3 Mar 2024 23:45:27 -1000 Subject: [PATCH 04/22] finally --- init.lua | 825 ------------------------------------------------------- 1 file changed, 825 deletions(-) diff --git a/init.lua b/init.lua index 0d401befb9f..c69576b0c98 100644 --- a/init.lua +++ b/init.lua @@ -822,828 +822,3 @@ require('lazy').setup { -- vim: ts=2 sts=2 sw=2 et vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) vim.api.nvim_set_keymap('x', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) -======= ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know how the Neovim basics, you can skip this step) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not sure exactly what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or neovim features used in kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your nvim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) ---]] - --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' - --- [[ Setting options ]] --- See `:help vim.opt` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` - --- Make line numbers default -vim.opt.number = true --- You can also add relative line numbers, for help with jumping. --- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true - --- Enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = 'a' - --- Don't show the mode, since it's already in status line -vim.opt.showmode = false - --- Sync clipboard between OS and Neovim. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` -vim.opt.clipboard = 'unnamedplus' - --- Enable break indent -vim.opt.breakindent = true - --- Save undo history -vim.opt.undofile = true - --- Case-insensitive searching UNLESS \C or capital in search -vim.opt.ignorecase = true -vim.opt.smartcase = true - --- Keep signcolumn on by default -vim.opt.signcolumn = 'yes' - --- Decrease update time -vim.opt.updatetime = 250 -vim.opt.timeoutlen = 300 - --- Configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = true - --- Sets how neovim will display certain whitespace in the editor. --- See `:help 'list'` --- and `:help 'listchars'` -vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } - --- Preview substitutions live, as you type! -vim.opt.inccommand = 'split' - --- Show which line your cursor is on -vim.opt.cursorline = true - --- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 - --- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` - --- Set highlight on search, but clear on pressing in normal mode -vim.opt.hlsearch = true -vim.keymap.set('n', '', 'nohlsearch') - --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) - --- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier --- for people to discover. Otherwise, you normally need to press , which --- is not what someone will guess without a bit more experience. --- --- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping --- or just use to exit terminal mode -vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - --- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') - --- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows --- --- See `:help wincmd` for a list of all window commands -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) - --- [[ Install `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.loop.fs_stat(lazypath) then - local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } -end ---@diagnostic disable-next-line: undefined-field -vim.opt.rtp:prepend(lazypath) - --- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- --- To update plugins, you can run --- :Lazy update --- --- NOTE: Here is where you install your plugins. -require('lazy').setup { - -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). - 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically - - -- NOTE: Plugins can also be added by using a table, - -- with the first argument being the link and the following - -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to force a plugin to be loaded. - -- - -- This is equivalent to: - -- require('Comment').setup({}) - - -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, - 'sainnhe/gruvbox-material', - - -- Here is a more advanced example where we pass configuration - -- options to `gitsigns.nvim`. This is equivalent to the following lua: - -- require('gitsigns').setup({ ... }) - -- - -- See `:help gitsigns` to understand what the configuration keys do - { -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, - }, - - -- NOTE: Plugins can also be configured to run lua code when they are loaded. - -- - -- This is often very useful to both group configuration, as well as handle - -- lazy loading plugins that don't need to be loaded immediately at startup. - -- - -- For example, in the following configuration, we use: - -- event = 'VimEnter' - -- - -- which loads which-key before all the UI elements are loaded. Events can be - -- normal autocommands events (`:help autocmd-events`). - -- - -- Then, because we use the `config` key, the configuration only runs - -- after the plugin has been loaded: - -- config = function() ... end - - { -- Useful plugin to show you pending keybinds. - 'folke/which-key.nvim', - event = 'VimEnter', -- Sets the loading event to 'VimEnter' - config = function() -- This is the function that runs, AFTER loading - require('which-key').setup() - - -- Document existing key chains - require('which-key').register { - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, - } - end, - }, - - -- NOTE: Plugins can specify dependencies. - -- - -- The dependencies are proper plugin specifications as well - anything - -- you do for a plugin at the top level, you can do for a dependency. - -- - -- Use the `dependencies` key to specify the dependencies of a particular plugin - - { -- Fuzzy Finder (files, lsp, etc) - 'nvim-telescope/telescope.nvim', - event = 'VimEnter', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for install instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires special font. - -- If you already have a Nerd Font, or terminal set up with fallback fonts - -- you can enable this - -- { 'nvim-tree/nvim-web-devicons' } - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of help_tags options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable telescope extensions, if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- Also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[S]earch [/] in Open Files' }) - - -- Shortcut for searching your neovim configuration files - vim.keymap.set('n', 'sn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) - end, - }, - - { -- LSP Configuration & Plugins - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs and related tools to stdpath for neovim - 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP. - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, - }, - config = function() - -- Brief Aside: **What is LSP?** - -- - -- LSP is an acronym you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc) - vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - - -- Find references for the word under your cursor. - map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - - -- Fuzzy find all the symbols in your current workspace - -- Similar to document symbols, except searches over your whole project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- Rename the variable under your cursor - -- Most Language Servers support renaming across files, etc. - map('rn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - - -- Opens a popup that displays documentation about the word under your cursor - -- See `:help K` for why this keymap - map('K', vim.lsp.buf.hover, 'Hover Documentation') - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header - map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.server_capabilities.documentHighlightProvider then - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - callback = vim.lsp.buf.clear_references, - }) - end - end, - }) - - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP Specification. - -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - - -- Enable the following language servers - -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. - -- - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, - -- - - lua_ls = { - -- cmd = {...}, - -- filetypes { ...}, - -- capabilities = {}, - settings = { - Lua = { - runtime = { version = 'LuaJIT' }, - workspace = { - checkThirdParty = false, - -- Tells lua_ls where to find all the Lua files that you have loaded - -- for your neovim configuration. - library = { - '${3rd}/luv/library', - unpack(vim.api.nvim_get_runtime_file('', true)), - }, - -- If lua_ls is really slow on your computer, you can try this instead: - -- library = { vim.env.VIMRUNTIME }, - }, - completion = { - callSnippet = 'Replace', - }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, - }, - }, - }, - } - - -- Ensure the servers and tools above are installed - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu - require('mason').setup() - - -- You can add other tools here that you want Mason to install - -- for you, so that they are available from within Neovim. - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'stylua', -- Used to format lua code - }) - require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - require('mason-lspconfig').setup { - handlers = { - function(server_name) - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for tsserver) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } - end, - }, - - { -- Autoformat - 'stevearc/conform.nvim', - opts = { - notify_on_error = false, - format_on_save = { - timeout_ms = 500, - lsp_fallback = true, - }, - formatters_by_ft = { - lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use a sub-list to tell conform to run *until* a formatter - -- is found. - -- javascript = { { "prettierd", "prettier" } }, - }, - }, - }, - - { -- Autocompletion - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - 'L3MON4D3/LuaSnip', - build = (function() - -- Build Step is needed for regex support in snippets - -- This step is not supported in many windows environments - -- Remove the below condition to re-enable on windows - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - }, - 'saadparwaiz1/cmp_luasnip', - - -- Adds other completion capabilities. - -- nvim-cmp does not ship with all sources by default. They are split - -- into multiple repos for maintenance purposes. - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-path', - - -- If you want to add a bunch of pre-configured snippets, - -- you can use this plugin to help you. It even has snippets - -- for various frameworks/libraries/etc. but you will have to - -- set up the ones that are useful for you. - -- 'rafamadriz/friendly-snippets', - }, - config = function() - -- See `:help cmp` - local cmp = require 'cmp' - local luasnip = require 'luasnip' - luasnip.config.setup {} - - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = 'menu,menuone,noinsert' }, - - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = cmp.mapping.preset.insert { - -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), - - -- Accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, - - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [''] = cmp.mapping.complete {}, - - -- Think of as moving to the right of your snippet expansion. - -- So if you have a snippet that's like: - -- function $name($args) - -- $body - -- end - -- - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [''] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - }, - } - end, - }, - - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme` - 'folke/tokyonight.nvim', - lazy = false, -- make sure we load this during startup if it is your main colorscheme - priority = 1000, -- make sure to load this before all the other start plugins - config = function() - -- Load the colorscheme here - vim.cmd.colorscheme 'gruvbox-material' - - -- You can configure highlights by doing something like - vim.cmd.hi 'Comment gui=none' - end, - }, - - -- Highlight todo, notes, etc in comments - { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - - { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [']quote - -- - ci' - [C]hange [I]nside [']quote - require('mini.ai').setup { n_lines = 500 } - - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() - - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - statusline.setup() - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we disable the section for - -- cursor information because line numbers are already enabled - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '' - end - - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim - end, - }, - - { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - config = function() - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { enable = true }, - indent = { enable = true }, - } - - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects - end, - }, - - -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the - -- init.lua. If you want these files, they are in the repository, so you can just download them and - -- put them in the right spots if you want. - - -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for kickstart - -- - -- Here are some example plugins that I've included in the kickstart repository. - -- Uncomment any of the lines below to enable them (you will need to restart nvim). - -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` - -- This is the easiest way to modularize your config. - -- - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, -} - --- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et -vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('x', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) From 5c014642a4f8595fb91f595646246442a0b194cf Mon Sep 17 00:00:00 2001 From: RiverMatsumoto <66350813+RiverMatsumoto@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:52:25 -1000 Subject: [PATCH 05/22] Update README.md --- README.md | 220 ------------------------------------------------------ 1 file changed, 220 deletions(-) diff --git a/README.md b/README.md index 26b2d5ae785..c7c6927b0b0 100644 --- a/README.md +++ b/README.md @@ -1,223 +1,3 @@ -<<<<<<< HEAD -# kickstart.nvim - -## Introduction - -A starting point for Neovim that is: - -* Small -* Single-file -* Completely Documented - -**NOT** a Neovim distribution, but instead a starting point for your configuration. - -## Installation - -### Install Neovim - -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. - -### Install External Dependencies - -> **NOTE** -> [Backup](#FAQ) your previous configuration (if any exists) - -External Requirements: -- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) -- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) -- Language Setup: - - If want to write Typescript, you need `npm` - - If want to write Golang, you will need `go` - - etc. - -> **NOTE** -> See [Windows Installation](#Windows-Installation) to double check any additional Windows notes - -Neovim's configurations are located under the following paths, depending on your OS: - -| OS | PATH | -| :- | :--- | -| Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` | -| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` | - -### Install Kickstart - -Clone kickstart.nvim: - -
Linux and Mac - -```sh -git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim -``` - -
- -
Windows - -If you're using `cmd.exe`: - -``` -git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ -``` - -If you're using `powershell.exe` - -``` -git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ -``` - -
- -### Post Installation - -Start Neovim - -```sh -nvim -``` - -That's it! Lazy will install all the plugins you have. Use `:Lazy` to view -current plugin status. - -Read through the `init.lua` file in your configuration folder for more -information about extending and exploring Neovim. - -### Getting Started - -See [Effective Neovim: Instant IDE](https://youtu.be/stqUbv-5u2s), covering the -previous version. Note: The install via init.lua is outdated, please follow the -install instructions in this file instead. An updated video is coming soon. - -### Recommended Steps - -[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo -(so that you have your own copy that you can modify) and then installing you -can install to your machine using the methods above. - -> **NOTE** -> Your fork's url will be something like this: `https://github.com//kickstart.nvim.git` - -#### Examples of adding popularly requested plugins - -NOTE: You'll need to uncomment the line in the init.lua that turns on loading custom plugins. - -
- Adding autopairs - -This will automatically install [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs) and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). - -In the file: `lua/custom/plugins/autopairs.lua`, add: - -```lua --- File: lua/custom/plugins/autopairs.lua - -return { - "windwp/nvim-autopairs", - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require("nvim-autopairs").setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require('nvim-autopairs.completion.cmp') - local cmp = require('cmp') - cmp.event:on( - 'confirm_done', - cmp_autopairs.on_confirm_done() - ) - end, -} -``` - -
-
- Adding a file tree plugin - -This will install the tree plugin and add the command `:Neotree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. - -In the file: `lua/custom/plugins/filetree.lua`, add: - -```lua --- Unless you are still migrating, remove the deprecated commands from v1.x -vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) - -return { - "nvim-neo-tree/neo-tree.nvim", - version = "*", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - }, - config = function () - require('neo-tree').setup {} - end, -} -``` - -
- -### FAQ - -* What should I do if I already have a pre-existing neovim configuration? - * You should back it up, then delete all files associated with it. - * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` -* Can I keep my existing configuration in parallel to kickstart? - * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` to maintain multiple configurations. For example you can install the kickstart configuration in `~/.config/nvim-kickstart` and create an alias: - ``` - alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim' - ``` - When you run Neovim using `nvim-kickstart` alias it will use the alternative config directory and the matching local directory `~/.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://github.com/folke/lazy.nvim#-uninstalling) information -* 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 `git clone` as a basis for their own. - As you progress in learning Neovim and Lua, you might consider splitting `init.lua` - into smaller parts. A fork of kickstart that does this while maintaining the exact - same functionality is available here: - * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) - * Discussions on this topic can be found here: - * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) - * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) - -### Windows Installation - -Installation may require installing build tools, and updating the run command for `telescope-fzf-native` - -See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) - -This requires: - -- Install CMake, and the Microsoft C++ Build Tools on Windows - -```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' } -``` - -Alternatively one can install gcc and make which don't require changing the config, -the easiest way is to use choco: - -1. install [chocolatey](https://chocolatey.org/install) -either follow the instructions on the page or use winget, -run in cmd as **admin**: -``` -winget install --accept-source-agreements chocolatey.chocolatey -``` - -2. install all requirements using choco, exit previous cmd and -open a new one so that choco path is set, run in cmd as **admin**: -``` -choco install -y neovim git ripgrep wget fd unzip gzip mingw make -``` - -Then continue with the [Install Kickstart](#Install-Kickstart) step. - - -======= # kickstart.nvim # install: From bc150433eb8972ba43a72b813fdb3b0d972ff2df Mon Sep 17 00:00:00 2001 From: RiverMatsumoto <66350813+RiverMatsumoto@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:53:30 -1000 Subject: [PATCH 06/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c7c6927b0b0..bb20f57b891 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # kickstart.nvim # install: -`https://github.com/RiverMatsumoto/kickstart.nvim.git` +`git clone https://github.com/RiverMatsumoto/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim` ## Introduction From 0ab4d2653dddebb375b7229d89b00fb97ec8965b Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Thu, 7 Mar 2024 00:33:59 -1000 Subject: [PATCH 07/22] custom plugin fixes --- init.lua | 7 +- lua/custom/plugins/gruvbox-material.lua | 134 ------------------------ 2 files changed, 4 insertions(+), 137 deletions(-) delete mode 100644 lua/custom/plugins/gruvbox-material.lua diff --git a/init.lua b/init.lua index c69576b0c98..1dbcd001009 100644 --- a/init.lua +++ b/init.lua @@ -532,9 +532,9 @@ require('lazy').setup { -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - -- clangd = {}, + clangd = {}, -- gopls = {}, - -- pyright = {}, + pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -815,10 +815,11 @@ require('lazy').setup { -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, } -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) vim.api.nvim_set_keymap('x', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) diff --git a/lua/custom/plugins/gruvbox-material.lua b/lua/custom/plugins/gruvbox-material.lua deleted file mode 100644 index 9ba37afb002..00000000000 --- a/lua/custom/plugins/gruvbox-material.lua +++ /dev/null @@ -1,134 +0,0 @@ --- ============================================================================= --- URL: https://github.com/sainnhe/gruvbox-material --- Filename: lua/lualine/themes/gruvbox-material.lua --- Author: sainnhe --- Email: i@sainnhe.dev --- License: MIT License --- ============================================================================= - -local configuration = vim.fn['gruvbox_material#get_configuration']() -local palette = vim.fn['gruvbox_material#get_palette'](configuration.background, configuration.foreground, configuration.colors_override) - -if configuration.transparent_background == 2 then - palette.bg_statusline1 = palette.none - palette.bg_statusline2 = palette.none -end - -local theme -if configuration.statusline_style == 'default' then - theme = { - normal = { - a = {bg = palette.grey2[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} - }, - insert = { - a = {bg = palette.bg_green[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} - }, - visual = { - a = {bg = palette.bg_red[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} - }, - replace = { - a = {bg = palette.bg_yellow[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} - }, - command = { - a = {bg = palette.blue[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} - }, - terminal = { - a = {bg = palette.purple[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline1[1], fg = palette.fg1[1]} - }, - inactive = { - a = {bg = palette.bg_statusline1[1], fg = palette.grey2[1]}, - b = {bg = palette.bg_statusline1[1], fg = palette.grey2[1]}, - c = {bg = palette.bg_statusline1[1], fg = palette.grey2[1]} - } - } -elseif configuration.statusline_style == 'mix' then - theme = { - normal = { - a = {bg = palette.grey2[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.grey2[1]}, - c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} - }, - insert = { - a = {bg = palette.bg_green[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} - }, - visual = { - a = {bg = palette.bg_red[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} - }, - replace = { - a = {bg = palette.bg_yellow[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} - }, - command = { - a = {bg = palette.blue[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} - }, - terminal = { - a = {bg = palette.purple[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline2[1], fg = palette.fg1[1]} - }, - inactive = { - a = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, - b = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, - c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} - } - } -else - theme = { - normal = { - a = {bg = palette.grey2[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.grey2[1]}, - c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} - }, - insert = { - a = {bg = palette.blue[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} - }, - visual = { - a = {bg = palette.orange[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.grey0[1], fg = palette.bg0[1]} - }, - replace = { - a = {bg = palette.aqua[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} - }, - command = { - a = {bg = palette.green[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} - }, - terminal = { - a = {bg = palette.purple[1], fg = palette.bg0[1], gui = 'bold'}, - b = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]}, - c = {bg = palette.bg_statusline3[1], fg = palette.fg1[1]} - }, - inactive = { - a = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, - b = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]}, - c = {bg = palette.bg_statusline2[1], fg = palette.grey2[1]} - } - } -end - -return theme From 0d8418543aeb8b0f5062f4f2cf04d103d2ab52f2 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Thu, 7 Mar 2024 01:53:59 -1000 Subject: [PATCH 08/22] Floaterm --- init.lua | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 1dbcd001009..f3d4dae81ee 100644 --- a/init.lua +++ b/init.lua @@ -160,6 +160,13 @@ vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D] vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +vim.api.nvim_set_keymap('n', '\\', ':Neotree toggle current reveal_force_cwd', { noremap = true }) +vim.api.nvim_set_keymap('n', '|', ':Neotree toggle reveal', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gd', ':Neotree float reveal_file= reveal_force_cwd', { noremap = true }) +vim.api.nvim_set_keymap('n', '', ':w', { noremap = true }) +vim.api.nvim_set_keymap('n', 'Y', 'yy', { noremap = true }) +vim.api.nvim_set_keymap('v', '', '"+y', { noremap = true }) +-- vim.api.nvim_set_keymap('i', '', '', { noremap = true }) -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which @@ -221,6 +228,7 @@ vim.opt.rtp:prepend(lazypath) require('lazy').setup { -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + 'voldikss/vim-floaterm', -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following @@ -532,7 +540,12 @@ require('lazy').setup { -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - clangd = {}, + clangd = { + -- cmd = { + -- 'clangd', + -- -- '--compile-commands-dir=build', + -- }, + }, -- gopls = {}, pyright = {}, -- rust_analyzer = {}, @@ -616,6 +629,7 @@ require('lazy').setup { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, + c = { 'clangd' }, -- -- You can use a sub-list to tell conform to run *until* a formatter -- is found. @@ -675,14 +689,14 @@ require('lazy').setup { -- No, but seriously. Please read `:help ins-completion`, it is really good! mapping = cmp.mapping.preset.insert { -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_next_item(), -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_prev_item(), -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.confirm { select = true }, -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display @@ -820,6 +834,10 @@ require('lazy').setup { -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et -vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('x', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) vim.api.nvim_set_keymap('i', '', '', { noremap = true }) + +-- map floaterm +vim.api.nvim_set_keymap('n', '', ':Floaterm toggle', { noremap = true }) +vim.api.nvim_set_keymap('i', '', ':Floaterm toggle', { noremap = true }) From 916dd9f9bd10d1174b109b2b3c49ec6c7a46155d Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Wed, 28 Aug 2024 00:13:37 -1000 Subject: [PATCH 09/22] ros2 stuff --- init.lua | 108 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 13 deletions(-) diff --git a/init.lua b/init.lua index f3d4dae81ee..6a53baf4254 100644 --- a/init.lua +++ b/init.lua @@ -125,6 +125,14 @@ vim.opt.smartcase = true -- Keep signcolumn on by default vim.opt.signcolumn = 'yes' +-- spaces instead of tab +vim.opt.expandtab = true + +-- tab width 4 +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 + -- Decrease update time vim.opt.updatetime = 250 vim.opt.timeoutlen = 300 @@ -164,6 +172,7 @@ vim.api.nvim_set_keymap('n', '\\', ':Neotree toggle current reveal_force_cwd vim.api.nvim_set_keymap('n', '|', ':Neotree toggle reveal', { noremap = true }) vim.api.nvim_set_keymap('n', 'gd', ':Neotree float reveal_file= reveal_force_cwd', { noremap = true }) vim.api.nvim_set_keymap('n', '', ':w', { noremap = true }) +vim.api.nvim_set_keymap('i', '', ':w', { noremap = true }) vim.api.nvim_set_keymap('n', 'Y', 'yy', { noremap = true }) vim.api.nvim_set_keymap('v', '', '"+y', { noremap = true }) -- vim.api.nvim_set_keymap('i', '', '', { noremap = true }) @@ -324,7 +333,7 @@ require('lazy').setup { -- Useful for getting pretty icons, but requires special font. -- If you already have a Nerd Font, or terminal set up with fallback fonts -- you can enable this - -- { 'nvim-tree/nvim-web-devicons' } + { 'nvim-tree/nvim-web-devicons' }, }, config = function() -- Telescope is a fuzzy finder that comes with a lot of different things that @@ -352,16 +361,36 @@ require('lazy').setup { -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} + defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + file_ignore_patterns = { + 'node_modules', + 'build', + '%.git$', + '%.cache$', + '%.o$', + '%.a$', + '%.out$', + '%.class$', + '%.pdf$', + '%.mkv$', + '%.mp4$', + '%.zip$', + '%.make$', + }, + }, + pickers = { + find_files = { + hidden = true, + }, + }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), }, + 'projects', }, } @@ -407,6 +436,21 @@ require('lazy').setup { end, }, + { + 'ErickKramer/nvim-ros2', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope.nvim', + 'nvim-treesitter/nvim-treesitter', + }, + opts = { + -- Add any custom options here + autocmds = true, + telescope = true, + treesitter = true, + }, + }, + { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { @@ -541,10 +585,10 @@ require('lazy').setup { -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { clangd = { - -- cmd = { - -- 'clangd', - -- -- '--compile-commands-dir=build', - -- }, + cmd = { + 'clangd', + '--compile-commands-dir=build', + }, }, -- gopls = {}, pyright = {}, @@ -839,5 +883,43 @@ vim.api.nvim_set_keymap('v', '', 'lua require("Comment.api").togg vim.api.nvim_set_keymap('i', '', '', { noremap = true }) -- map floaterm -vim.api.nvim_set_keymap('n', '', ':Floaterm toggle', { noremap = true }) -vim.api.nvim_set_keymap('i', '', ':Floaterm toggle', { noremap = true }) +vim.api.nvim_set_keymap('n', '', ':FloatermToggle', { noremap = true }) +vim.api.nvim_set_keymap('i', '', ':FloatermToggle', { noremap = true }) +vim.api.nvim_set_keymap('t', '', ':FloatermToggle', { noremap = true, silent = true }) +-- +-- Define the toggle function +local function toggle_neotree() + local manager = require 'neo-tree.sources.manager' + local renderer = require 'neo-tree.ui.renderer' + + local state = manager.get_state 'filesystem' + local window_exists = renderer.window_exists(state) + if window_exists then + vim.cmd 'Neotree close' + else + vim.cmd 'Neotree show' + end +end + +-- Ensure the function is accessible +_G.toggle_neotree = toggle_neotree + +-- Map the toggle function to a key command +vim.api.nvim_set_keymap('n', '', ':lua toggle_neotree()', { noremap = true, silent = true }) + +-- vim.api.nvim_set_keymap('n', '', ':lua toggle_neotree()', { noremap = true, silent = true }) +-- vim.api.nvim_set_keymap('i', '', ':lua toggle_neotree()', { noremap = true, silent = true }) + +vim.api.nvim_set_keymap('i', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) + +vim.api.nvim_create_augroup('EnsureTextWindowFocus', { clear = true }) + +vim.api.nvim_create_autocmd('VimEnter', { + group = 'EnsureTextWindowFocus', + callback = function() + vim.defer_fn(function() + vim.cmd 'wincmd p' + end, 100) -- Adjust the delay if necessary + end, +}) From 6c9967c938749a7695b8d7c211dcdcb5cd35ca95 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Wed, 28 Aug 2024 23:38:25 -1000 Subject: [PATCH 10/22] ros2 mappings --- init.lua | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 6a53baf4254..8ecf9f94bc2 100644 --- a/init.lua +++ b/init.lua @@ -115,6 +115,10 @@ vim.opt.clipboard = 'unnamedplus' -- Enable break indent vim.opt.breakindent = true +-- indentation +-- vim.opt.autoindent = true +-- vim.opt.smartindent = true + -- Save undo history vim.opt.undofile = true @@ -129,9 +133,9 @@ vim.opt.signcolumn = 'yes' vim.opt.expandtab = true -- tab width 4 -vim.opt.shiftwidth = 4 -vim.opt.tabstop = 4 -vim.opt.softtabstop = 4 +-- vim.opt.shiftwidth = 4 +-- vim.opt.tabstop = 4 +-- vim.opt.softtabstop = 4 -- Decrease update time vim.opt.updatetime = 250 @@ -250,8 +254,15 @@ require('lazy').setup { -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, - 'sainnhe/gruvbox-material', - + -- 'sainnhe/gruvbox-material', + 'nvim-lualine/lualine.nvim', + { + 'f4z3r/gruvbox-material.nvim', + name = 'gruvbox-material', + lazy = false, + priority = 1000, + opts = {}, + }, -- Here is a more advanced example where we pass configuration -- options to `gitsigns.nvim`. This is equivalent to the following lua: -- require('gitsigns').setup({ ... }) @@ -866,7 +877,7 @@ require('lazy').setup { -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.indent_line', -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. @@ -923,3 +934,17 @@ vim.api.nvim_create_autocmd('VimEnter', { end, 100) -- Adjust the delay if necessary end, }) + +-- tabstop 2 +vim.api.nvim_create_augroup('CppIndent', { clear = true }) + +-- Set tab width to 2 spaces for C++ files +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'cpp', 'c', 'cc', 'h', 'hpp' }, + group = 'CppIndent', + callback = function() + vim.opt_local.tabstop = 2 + vim.opt_local.shiftwidth = 2 + vim.opt_local.expandtab = true + end, +}) From d53a7d70064b7724da79996ec7fa0f0e4f0d22f4 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Thu, 3 Oct 2024 18:53:41 -1000 Subject: [PATCH 11/22] init.lua update --- init.lua | 2077 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 1397 insertions(+), 680 deletions(-) diff --git a/init.lua b/init.lua index 8ecf9f94bc2..eb8456a0d7e 100644 --- a/init.lua +++ b/init.lua @@ -1,543 +1,609 @@ --[[ - ===================================================================== ==================== READ THIS BEFORE CONTINUING ==================== ===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know how the Neovim basics, you can skip this step) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. + ros2-with-neovim is heavily inspired from Kickstart.nvim. - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite neovim features. + I have basically taken the same approach of having a single file where all the + main configurations are done commenting clearly what all of them do. - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not sure exactly what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or neovim features used in kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your nvim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) + You should consider this as a starting point into your Neovim journey. Then, you can + start to add as many plugins and configurations as you see fit :). --]] - -- Set as the leader key -- See `:help mapleader` --- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) +-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' --- [[ Setting options ]] --- See `:help vim.opt` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` - --- Make line numbers default -vim.opt.number = true --- You can also add relative line numbers, for help with jumping. --- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true - --- Enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = 'a' - --- Don't show the mode, since it's already in status line -vim.opt.showmode = false +-- Install package manager +-- https://github.com/folke/lazy.nvim +-- `:help lazy.nvim.txt` for more info +-- INFO: There are different plugins manager for neovim. I prefer Lazy +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release + lazypath, + } +end --- Sync clipboard between OS and Neovim. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` -vim.opt.clipboard = 'unnamedplus' +vim.opt.rtp:prepend(lazypath) --- Enable break indent -vim.opt.breakindent = true +-- NOTE: Here is where you install your plugins. +-- You can configure plugins using the `config` key. +-- You can also configure plugins after the setup call, +-- as they will be available in your neovim runtime. +require('lazy').setup({ + -- INFO: Git related plugins + 'voldikss/vim-floaterm', + 'tpope/vim-fugitive', -- Git wrapper for vim + 'rhysd/conflict-marker.vim', -- weapon to fight against merge conflicts + { 'numToStr/Comment.nvim', opts = {} }, + 'rhysd/git-messenger.vim', -- Shows commit message under cursor + { + 'lewis6991/gitsigns.nvim', -- Similar to fugitive, but adds additiona functionality + event = 'VeryLazy', + config = function() + require('gitsigns').setup { + signs = { + add = { text = '│' }, + change = { text = '│' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + } + end, + }, + { + 'sindrets/diffview.nvim', -- Single tabpage interface for easily cycling through diffs + event = 'VeryLazy', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + }, + { -- Quick selection of co-authors + 'ErickKramer/git-coauthors.nvim', + dependencies = { + 'nvim-telescope/telescope.nvim', + }, + }, --- indentation --- vim.opt.autoindent = true --- vim.opt.smartindent = true + -- INFO: Enhance Editor Experience + { + 'iamcco/markdown-preview.nvim', -- Markdown previewer + -- event = "VeryLazy", + build = function() + vim.fn['mkdp#util#install']() + end, + config = function() + -- Refresh markdown when saving the buffer or leaving insert mode + vim.g.mkdp_refresh_slow = 1 --- Save undo history -vim.opt.undofile = true + -- Fancy title + vim.g.mkdp_page_title = '「${name}」' --- Case-insensitive searching UNLESS \C or capital in search -vim.opt.ignorecase = true -vim.opt.smartcase = true + -- Dark mode (of course) + vim.g.mkdp_theme = 'dark' --- Keep signcolumn on by default -vim.opt.signcolumn = 'yes' + -- Avoid auto close + vim.g.mkdp_auto_close = 0 --- spaces instead of tab -vim.opt.expandtab = true + vim.g.mkdp_combine_preview = 1 + vim.g.mkdp_combine_preview_auto_refresh = 1 + end, + }, + { -- You can easily change to a different colorscheme. + -- Change the name of the colorscheme plugin below, and then + -- change the command in the config to whatever the name of that colorscheme is + -- + -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme` + 'folke/tokyonight.nvim', + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins + config = function() + -- Load the colorscheme here + vim.cmd.colorscheme 'gruvbox-material' --- tab width 4 --- vim.opt.shiftwidth = 4 --- vim.opt.tabstop = 4 --- vim.opt.softtabstop = 4 + -- You can configure highlights by doing something like + vim.cmd.hi 'Comment gui=none' + end, + }, + { + 'f4z3r/gruvbox-material.nvim', + name = 'gruvbox-material', + lazy = false, + priority = 1000, + opts = {}, + }, + 'mg979/vim-visual-multi', -- Enable multicursor + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + } + }, + 'nvim-tree/nvim-web-devicons', -- Add fancy icons + -- { + -- 'nvim-tree/nvim-tree.lua', -- File tree + -- config = function() + -- -- Config needed for nvim-tree + -- vim.g.loaded_netrw = 1 + -- vim.g.loaded_netrwPlugin = 1 + -- require('nvim-tree').setup { + -- sort_by = 'case_sensitive', + -- view = { + -- adaptive_size = false, + -- relativenumber = true, + -- width = 40, + -- }, + -- renderer = { + -- group_empty = true, + -- }, + -- filters = { + -- dotfiles = true, + -- }, + -- } + -- end, + -- }, + { + 'folke/todo-comments.nvim', -- Fancy TODOs/FIXMEs + dependencies = 'nvim-lua/plenary.nvim', + opts = {}, + }, + { -- Improve file navigation with search labels + 'folke/flash.nvim', + event = 'VeryLazy', + ---@type Flash.Config + opts = {}, + keys = { + { + 's', + mode = { 'n', 'x', 'o' }, + function() + require('flash').jump() + end, + desc = 'Flash', + }, + { + 'S', + mode = { 'n', 'x', 'o' }, + function() + require('flash').treesitter() + end, + desc = 'Flash Treesitter', + }, + { + 'r', + mode = 'o', + function() + require('flash').remote() + end, + desc = 'Remote Flash', + }, + { + 'R', + mode = { 'o', 'x' }, + function() + require('flash').treesitter_search() + end, + desc = 'Treesitter Search', + }, + -- { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, + }, + }, + { + 'folke/trouble.nvim', -- Quickfix list for LSP errors + dependencies = 'nvim-tree/nvim-web-devicons', + config = function() + require('trouble').setup { + signs = { + -- icons / text used for a diagnostic + error = '', + warning = '', + hint = '', + information = '', + other = '﫠', + }, + } + end, + }, + { + 'folke/which-key.nvim', -- Popup with possible keybindings of the command you started to type + opts = {}, + }, + { + 'nvim-lualine/lualine.nvim', -- Fancier statusline + config = function() + local function get_venv() + local venv = vim.env.VIRTUAL_ENV + if venv then + local env = string.match(venv, '[^/]+$') + return ' ' .. env + else + return '' + end + end --- Decrease update time -vim.opt.updatetime = 250 -vim.opt.timeoutlen = 300 + local ros_distro = vim.fn.expand '$ROS_DISTRO' --- Configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = true + local function get_ros_distro() + if ros_distro and ros_distro ~= '$ROS_DISTRO' then + return '󰭆 ' .. ros_distro + else + return '' + end + end + require('lualine').setup { + options = { + icons_enabled = true, + theme = 'onedark', + component_separators = '|', + section_separators = '', + ignore_focus = { + 'dapui_watches', + 'dapui_breakpoints', + 'dapui_scopes', + 'dapui_console', + 'dapui_stacks', + 'dap-repl', + }, + disabled_filetypes = { 'NvimTree' }, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { 'filename' }, + lualine_x = { { get_venv }, { get_ros_distro }, 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + } + end, + }, + { + 'nvim-pack/nvim-spectre', -- Advance Search and Replace + opts = {}, + }, + { + 'goolord/alpha-nvim', -- Greeter dashboard + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + local alpha = require 'alpha' + local dashboard = require 'alpha.themes.dashboard' + dashboard.section.header.val = { + [[██████╗ ██████╗ ███████╗]], + [[██╔══██╗██╔═══██╗██╔════╝]], + [[██████╔╝██║ ██║███████╗]], + [[██╔══██╗██║ ██║╚════██║]], + [[██║ ██║╚██████╔╝███████║]], + [[╚═╝ ╚═╝ ╚═════╝ ╚══════╝]], + } + dashboard.section.buttons.val = { + dashboard.button('f', ' Find file', ':Telescope find_files '), + dashboard.button('t', ' Find text', ':Telescope live_grep '), + dashboard.button('n', ' New file', ':ene startinsert '), + dashboard.button('c', ' Configuration', ':e ~/.config/nvim/init.lua '), + dashboard.button('u', ' Update plugins', ':Lazy sync'), + dashboard.button('q', ' Quit', ':qa'), + } + local handle = io.popen 'fortune' + local fortune = handle:read '*a' + handle:close() + dashboard.section.footer.val = fortune --- Sets how neovim will display certain whitespace in the editor. --- See `:help 'list'` --- and `:help 'listchars'` -vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + dashboard.config.opts.noautocmd = true --- Preview substitutions live, as you type! -vim.opt.inccommand = 'split' + vim.cmd [[autocmd User AlphaReady echo 'ready']] --- Show which line your cursor is on -vim.opt.cursorline = true + alpha.setup(dashboard.config) + end, + }, + { + 'romgrk/barbar.nvim', -- Tabline plugin that improves buffers and tabs + event = 'BufEnter', + dependencies = 'nvim-tree/nvim-web-devicons', + init = function() + vim.g.barbar_auto_setup = false + end, + lazy = true, + }, + { + -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help indent_blankline.txt` + main = 'ibl', + opts = {}, + config = function() + local highlight = { + 'RainbowRed', + 'RainbowYellow', + 'RainbowBlue', + 'RainbowOrange', + 'RainbowGreen', + 'RainbowViolet', + 'RainbowCyan', + } --- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 + local hooks = require 'ibl.hooks' + -- create the highlight groups in the highlight setup hook, so they are reset + -- every time the colorscheme changes + hooks.register(hooks.type.HIGHLIGHT_SETUP, function() + vim.api.nvim_set_hl(0, 'RainbowRed', { fg = '#E06C75' }) + vim.api.nvim_set_hl(0, 'RainbowYellow', { fg = '#E5C07B' }) + vim.api.nvim_set_hl(0, 'RainbowBlue', { fg = '#61AFEF' }) + vim.api.nvim_set_hl(0, 'RainbowOrange', { fg = '#D19A66' }) + vim.api.nvim_set_hl(0, 'RainbowGreen', { fg = '#98C379' }) + vim.api.nvim_set_hl(0, 'RainbowViolet', { fg = '#C678DD' }) + vim.api.nvim_set_hl(0, 'RainbowCyan', { fg = '#56B6C2' }) + end) + require('ibl').setup { + indent = { highlight = highlight, char = '┊' }, + scope = { enabled = false }, + } + end, + }, + { + 'akinsho/toggleterm.nvim', -- Improve handling neovim terminals + opts = {}, + config = function() + require('toggleterm').setup { + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + persist_size = true, + direction = 'float', + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = 'curved', + winblend = 0, + highlights = { + border = 'Normal', + background = 'Normal', + }, + }, + } + function _G.set_terminal_keymaps() + local opts = { noremap = true } + vim.diagnostic.disable(0) + vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + end --- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` + -- ==================================================== + -- Custom terminals + -- ==================================================== + vim.cmd 'autocmd! TermOpen term://* lua set_terminal_keymaps()' --- Set highlight on search, but clear on pressing in normal mode -vim.opt.hlsearch = true -vim.keymap.set('n', '', 'nohlsearch') + local Terminal = require('toggleterm.terminal').Terminal --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) -vim.api.nvim_set_keymap('n', '\\', ':Neotree toggle current reveal_force_cwd', { noremap = true }) -vim.api.nvim_set_keymap('n', '|', ':Neotree toggle reveal', { noremap = true }) -vim.api.nvim_set_keymap('n', 'gd', ':Neotree float reveal_file= reveal_force_cwd', { noremap = true }) -vim.api.nvim_set_keymap('n', '', ':w', { noremap = true }) -vim.api.nvim_set_keymap('i', '', ':w', { noremap = true }) -vim.api.nvim_set_keymap('n', 'Y', 'yy', { noremap = true }) -vim.api.nvim_set_keymap('v', '', '"+y', { noremap = true }) --- vim.api.nvim_set_keymap('i', '', '', { noremap = true }) - --- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier --- for people to discover. Otherwise, you normally need to press , which --- is not what someone will guess without a bit more experience. --- --- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping --- or just use to exit terminal mode -vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - --- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') - --- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows --- --- See `:help wincmd` for a list of all window commands -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) + local lazygit = Terminal:new { + cmd = 'lazygit', + hidden = true, + direction = 'float', + float_opts = { -- Get floating window in full screen + width = vim.o.columns, + height = vim.o.lines, + }, + on_open = function(term) + vim.cmd 'startinsert!' + vim.diagnostic.disable(0) + vim.api.nvim_buf_set_keymap(0, 't', '', 'close', { silent = false, noremap = true }) + if vim.fn.mapcheck('', 't') ~= '' then + vim.api.nvim_buf_del_keymap(term.bufnr, 't', '') + end + end, + } --- [[ 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.loop.fs_stat(lazypath) then - local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } -end ---@diagnostic disable-next-line: undefined-field -vim.opt.rtp:prepend(lazypath) + function _lazygit_toggle() + -- lazygit.dir = vim.fn.getcwd() -- Open lazygit in the current working directory + lazygit.dir = vim.fn.expand '%:p:h' -- Open lazygit in the repository from the file + lazygit:toggle() + end --- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- --- To update plugins, you can run --- :Lazy update --- --- NOTE: Here is where you install your plugins. -require('lazy').setup { - -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). - 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically - 'voldikss/vim-floaterm', + local python = Terminal:new { + cmd = 'ipython3', + direction = 'horizontal', + hidden = true, + hidden_numbers = true, + } - -- NOTE: Plugins can also be added by using a table, - -- with the first argument being the link and the following - -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to force a plugin to be loaded. - -- - -- This is equivalent to: - -- require('Comment').setup({}) + function _python_toggle() + python:toggle() + end - -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, - -- 'sainnhe/gruvbox-material', - 'nvim-lualine/lualine.nvim', + -- Fancy terminals + vim.api.nvim_set_keymap('n', 'lg', 'lua _lazygit_toggle()', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'ip', 'lua _python_toggle()', { noremap = true, silent = true }) + end, + }, { - 'f4z3r/gruvbox-material.nvim', - name = 'gruvbox-material', - lazy = false, - priority = 1000, + 'stevearc/dressing.nvim', opts = {}, - }, - -- Here is a more advanced example where we pass configuration - -- options to `gitsigns.nvim`. This is equivalent to the following lua: - -- require('gitsigns').setup({ ... }) - -- - -- See `:help gitsigns` to understand what the configuration keys do - { -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, - }, - - -- NOTE: Plugins can also be configured to run lua code when they are loaded. - -- - -- This is often very useful to both group configuration, as well as handle - -- lazy loading plugins that don't need to be loaded immediately at startup. - -- - -- For example, in the following configuration, we use: - -- event = 'VimEnter' - -- - -- which loads which-key before all the UI elements are loaded. Events can be - -- normal autocommands events (`:help autocmd-events`). - -- - -- Then, because we use the `config` key, the configuration only runs - -- after the plugin has been loaded: - -- config = function() ... end - - { -- Useful plugin to show you pending keybinds. - 'folke/which-key.nvim', - event = 'VimEnter', -- Sets the loading event to 'VimEnter' - config = function() -- This is the function that runs, AFTER loading - require('which-key').setup() - - -- Document existing key chains - require('which-key').register { - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, + config = function() + require('dressing').setup { + input = { + get_config = function() + return { + title_pos = 'center', + win_options = { + sidescrolloff = 10, + }, + insert_only = false, + } + end, + }, } end, }, - - -- NOTE: Plugins can specify dependencies. - -- - -- The dependencies are proper plugin specifications as well - anything - -- you do for a plugin at the top level, you can do for a dependency. - -- - -- Use the `dependencies` key to specify the dependencies of a particular plugin - - { -- Fuzzy Finder (files, lsp, etc) + { -- Color theme + 'navarasu/onedark.nvim', + priority = 1000, + -- config = function() + -- vim.cmd.colorscheme 'onedark' + -- end, + }, + -- Fuzzy Finder (files, lsp, etc) + { 'nvim-telescope/telescope.nvim', - event = 'VimEnter', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for install instructions + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. cond = function() return vim.fn.executable 'make' == 1 end, }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires special font. - -- If you already have a Nerd Font, or terminal set up with fallback fonts - -- you can enable this - { 'nvim-tree/nvim-web-devicons' }, + 'benfowler/telescope-luasnip.nvim', -- Allows to search the available snippet + 'nvim-telescope/telescope-live-grep-args.nvim', -- Enable passing arguments to ripgrep }, config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of help_tags options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - file_ignore_patterns = { - 'node_modules', - 'build', - '%.git$', - '%.cache$', - '%.o$', - '%.a$', - '%.out$', - '%.class$', - '%.pdf$', - '%.mkv$', - '%.mp4$', - '%.zip$', - '%.make$', + prompt_prefix = '🔍 ', + vimgrep_arguments = { + 'rg', + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + '--smart-case', + '--follow', + }, + path_display = { + truncate = 3, }, }, pickers = { find_files = { - hidden = true, + find_command = { + 'rg', + '--files', + '--hidden', + '-g', + '!.git', + }, + follow = true, + }, + lsp_document_symbols = { + show_line = true, }, }, extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = 'smart_case', -- or "ignore_case" or "respect_case" }, - 'projects', }, } - - -- Enable telescope extensions, if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- Also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[S]earch [/] in Open Files' }) - - -- Shortcut for searching your neovim configuration files - vim.keymap.set('n', 'sn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) + require('telescope').load_extension 'fzf' + require('telescope').load_extension 'luasnip' + require('telescope').load_extension 'live_grep_args' + require('telescope').load_extension 'coauthors' end, }, + -- + -- NOTE: This is where your plugins related to LSP can be installed. + -- The configuration is done below. Search for lspconfig to find it below. { - 'ErickKramer/nvim-ros2', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope.nvim', - 'nvim-treesitter/nvim-treesitter', - }, - opts = { - -- Add any custom options here - autocmds = true, - telescope = true, - treesitter = true, - }, - }, - - { -- LSP Configuration & Plugins + -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { - -- Automatically install LSPs and related tools to stdpath for neovim - 'williamboman/mason.nvim', + -- Automatically install LSPs to stdpath for neovim + { 'williamboman/mason.nvim', config = true }, 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', - -- Useful status updates for LSP. - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, + -- Useful status updates for LSP + { + 'j-hui/fidget.nvim', + config = function() + require('fidget').setup { + -- Options related to notification subsystem + notification = { + -- Options related to the notification window and buffer + window = { + normal_hl = 'Comment', -- Base highlight group in the notification window + border = 'rounded', -- Border around the notification window + zindex = 45, -- Stacking priority of the notification window + max_width = 0, -- Maximum width of the notification window + max_height = 0, -- Maximum height of the notification window + x_padding = 1, -- Padding from right edge of window boundary + y_padding = 0, -- Padding from bottom edge of window boundary + align = 'bottom', -- How to align the notification window + relative = 'editor', -- What the notification window position is relative to + }, + }, + } + end, + }, }, config = function() - -- Brief Aside: **What is LSP?** - -- - -- LSP is an acronym you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer + -- INFO: LSP Settings + -- This contains the configuration of several components related to LSPs + -- - luasnip + -- - mason + -- - mason-lspconfig + -- - nvim-cmp + -- - nvim-lspconfig + + -- PERF: + -- ==================================================== + -- LSP Keymaps + -- ==================================================== + + -- This function gets run when an LSP connects to a particular buffer. vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + group = vim.api.nvim_create_augroup('personal-lsp-attach', { clear = true }), callback = function(event) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. + -- Create a wrapper function to simplify keymaps creation local map = function(keys, func, desc) vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end - -- Jump to the definition of the word under your cursor. + -- Jump to the definition of the word under your cursor. -- This is where a variable was first declared, or where a function is defined, etc. -- To jump back, press . map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - -- Find references for the word under your cursor. map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - -- Jump to the implementation of the word under your cursor. -- Useful when your language has ways of declaring types without an actual implementation. map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - -- Jump to the type of the word under your cursor. -- Useful when you're not sure what type a variable is and you want to see -- the definition of its *type*, not where it was *defined*. map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - -- Fuzzy find all the symbols in your current document. -- Symbols are things like variables, functions, types, etc. map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - -- Fuzzy find all the symbols in your current workspace -- Similar to document symbols, except searches over your whole project. map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') @@ -545,7 +611,6 @@ require('lazy').setup { -- Rename the variable under your cursor -- Most Language Servers support renaming across files, etc. map('rn', vim.lsp.buf.rename, '[R]e[n]ame') - -- Execute a code action, usually your cursor needs to be on top of an error -- or a suggestion from your LSP for this to activate. map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') @@ -553,15 +618,10 @@ require('lazy').setup { -- Opens a popup that displays documentation about the word under your cursor -- See `:help K` for why this keymap map('K', vim.lsp.buf.hover, 'Hover Documentation') - - -- WARN: This is not Goto Definition, this is Goto Declaration. + map('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- NOTE: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header - map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- -- When you move your cursor, the highlights will be cleared (the second autocommand). local client = vim.lsp.get_client_by_id(event.data.client_id) if client and client.server_capabilities.documentHighlightProvider then @@ -578,85 +638,85 @@ require('lazy').setup { end, }) - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP Specification. - -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - - -- Enable the following language servers - -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. - -- - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + -- PERF: + -- ==================================================== + -- LSP Servers + -- ==================================================== local servers = { clangd = { cmd = { + -- see clangd --help-hidden 'clangd', - '--compile-commands-dir=build', + '--background-index', + -- by default, clang-tidy use -checks=clang-diagnostic-*,clang-analyzer-* + -- to add more checks, create .clang-tidy file in the root directory + -- and add Checks key, see https://clang.llvm.org/extra/clang-tidy/ + '--clang-tidy', + '--completion-style=bundled', + '--cross-file-rename', + '--header-insertion=iwyu', + }, + }, + pyright = { + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = 'openFilesOnly', + useLibraryCodeForTypes = true, + reportDuplicateImport = true, + }, }, }, - -- gopls = {}, - pyright = {}, - -- rust_analyzer = {}, - -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, - -- - lua_ls = { - -- cmd = {...}, - -- filetypes { ...}, - -- capabilities = {}, settings = { Lua = { runtime = { version = 'LuaJIT' }, workspace = { checkThirdParty = false, - -- Tells lua_ls where to find all the Lua files that you have loaded - -- for your neovim configuration. library = { '${3rd}/luv/library', unpack(vim.api.nvim_get_runtime_file('', true)), }, - -- If lua_ls is really slow on your computer, you can try this instead: - -- library = { vim.env.VIMRUNTIME }, }, completion = { callSnippet = 'Replace', }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, }, }, }, } - -- Ensure the servers and tools above are installed - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu - require('mason').setup() - - -- You can add other tools here that you want Mason to install - -- for you, so that they are available from within Neovim. - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'stylua', -- Used to format lua code - }) - require('mason-tool-installer').setup { ensure_installed = ensure_installed } + -- PERF: + -- ==================================================== + -- capabilities Configuratioon + -- ==================================================== + + -- nvim-cmp supports additional completion capabilities, so broadcast that to servers + local capabilities = vim.lsp.protocol.make_client_capabilities() + -- capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = false + capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + capabilities.offsetEncoding = { 'utf-16' } + capabilities.textDocument.completion.completionItem.snippetSupport = true + + -- Enable folding (for nvim-ufo) + capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, + } + + -- PERF: + -- ==================================================== + -- Mason Configuratioon + -- ==================================================== + + -- Setup mason so it can manage external tooling + require('mason').setup { + ui = { + border = 'rounded', + }, + } + -- mason-lspconfig configurations require('mason-lspconfig').setup { handlers = { function(server_name) @@ -669,66 +729,62 @@ require('lazy').setup { end, }, } - end, - }, + require('mason-tool-installer').setup { + + -- List of all DAP, Linter and Formatters to install + ensure_installed = { + -- LSPs + 'clangd', + 'lua_ls', + 'pyright', + 'ruff', + + -- DAP + 'codelldb', + 'cpptools', + + -- Linter + 'cpplint', + + -- Formatters + 'stylua', + 'prettier', + }, - { -- Autoformat - 'stevearc/conform.nvim', - opts = { - notify_on_error = false, - format_on_save = { - timeout_ms = 500, - lsp_fallback = true, - }, - formatters_by_ft = { - lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - c = { 'clangd' }, - -- - -- You can use a sub-list to tell conform to run *until* a formatter - -- is found. - -- javascript = { { "prettierd", "prettier" } }, - }, - }, - }, + -- if set to true this will check each tool for updates. If updates + -- are available the tool will be updated. This setting does not + -- affect :MasonToolsUpdate or :MasonToolsInstall. + -- Default: false + auto_update = false, + + -- automatically install / update on startup. If set to false nothing + -- will happen on startup. You can use :MasonToolsInstall or + -- :MasonToolsUpdate to install tools and check for updates. + -- Default: true + run_on_start = true, + + -- set a delay (in ms) before the installation starts. This is only + -- effective if run_on_start is set to true. + -- e.g.: 5000 = 5 second delay, 10000 = 10 second delay, etc... + -- Default: 0 + start_delay = 3000, -- 3 second delay + + -- Only attempt to install if 'debounce_hours' number of hours has + -- elapsed since the last time Neovim was started. This stores a + -- timestamp in a file named stdpath('data')/mason-tool-installer-debounce. + -- This is only relevant when you are using 'run_on_start'. It has no + -- effect when running manually via ':MasonToolsInstall' etc.... + -- Default: nil + debounce_hours = 5, -- at least 5 hours between attempts to install/update + } - { -- Autocompletion - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - 'L3MON4D3/LuaSnip', - build = (function() - -- Build Step is needed for regex support in snippets - -- This step is not supported in many windows environments - -- Remove the below condition to re-enable on windows - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - }, - 'saadparwaiz1/cmp_luasnip', + -- PERF: + -- ==================================================== + -- nvim-cmp configuration + -- ==================================================== - -- Adds other completion capabilities. - -- nvim-cmp does not ship with all sources by default. They are split - -- into multiple repos for maintenance purposes. - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-path', - - -- If you want to add a bunch of pre-configured snippets, - -- you can use this plugin to help you. It even has snippets - -- for various frameworks/libraries/etc. but you will have to - -- set up the ones that are useful for you. - -- 'rafamadriz/friendly-snippets', - }, - config = function() - -- See `:help cmp` local cmp = require 'cmp' local luasnip = require 'luasnip' - luasnip.config.setup {} cmp.setup { snippet = { @@ -736,156 +792,811 @@ require('lazy').setup { luasnip.lsp_expand(args.body) end, }, - completion = { completeopt = 'menu,menuone,noinsert' }, - - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! + -- performance = { + -- max_view_entries = 20, + -- }, mapping = cmp.mapping.preset.insert { - -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), - - -- Accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, - - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [''] = cmp.mapping.complete {}, - - -- Think of as moving to the right of your snippet expansion. - -- So if you have a snippet that's like: - -- function $name($args) - -- $body - -- end - -- - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [''] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() + else + fallback() end end, { 'i', 's' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then luasnip.jump(-1) + else + fallback() end end, { 'i', 's' }), }, sources = { - { name = 'nvim_lsp' }, + { name = 'nvim_lsp', max_item_count = 10 }, { name = 'luasnip' }, - { name = 'path' }, + { name = 'path', max_item_count = 5 }, + { name = 'buffer', max_item_count = 5 }, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), }, } - end, - }, - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme` - 'folke/tokyonight.nvim', - lazy = false, -- make sure we load this during startup if it is your main colorscheme - priority = 1000, -- make sure to load this before all the other start plugins - config = function() - -- Load the colorscheme here - vim.cmd.colorscheme 'gruvbox-material' + -- Suggested approach to cancel snippet session after going back to normal mode + -- Taken from https://github.com/L3MON4D3/LuaSnip/issues/258#issuecomment-1011938524 + function leave_snippet() + if + ((vim.v.event.old_mode == 's' and vim.v.event.new_mode == 'n') or vim.v.event.old_mode == 'i') + and require('luasnip').session.current_nodes[vim.api.nvim_get_current_buf()] + and not require('luasnip').session.jump_active + then + require('luasnip').unlink_current() + end + end - -- You can configure highlights by doing something like - vim.cmd.hi 'Comment gui=none' - end, - }, + -- stop snippets when you leave to normal mode + vim.api.nvim_command [[ autocmd ModeChanged * lua leave_snippet() ]] + + -- Custom command to disable completion + local cmp_enabled = true + vim.api.nvim_create_user_command('ToggleAutoComplete', function() + if cmp_enabled then + require('cmp').setup.buffer { enabled = false } + cmp_enabled = false + else + require('cmp').setup.buffer { enabled = true } + cmp_enabled = true + end + end, {}) + + -- Configure cmp-cmdline + cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' }, + }, + }) + -- `:` cmdline setup. + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' }, + }, { + { + name = 'cmdline', + option = { + ignore_cmds = { 'Man', '!' }, + }, + }, + }), + }) - -- Highlight todo, notes, etc in comments - { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + -- PERF: + -- ==================================================== + -- LSP related UI Configurations + -- ==================================================== - { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [']quote - -- - ci' - [C]hange [I]nside [']quote - require('mini.ai').setup { n_lines = 500 } + -- Add bordered to LSP info + require('lspconfig.ui.windows').default_options.border = 'rounded' - -- 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' - statusline.setup() - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we disable the section for - -- cursor information because line numbers are already enabled - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '' + -- INFO: Configure LSP textDocuments + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' }) + + vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded' }) + + -- Diagnostic signs + local diagnostic_signs = { + { name = 'DiagnosticSignError', text = ' ' }, + { name = 'DiagnosticSignWarn', text = ' ' }, + { name = 'DiagnosticSignHint', text = ' ' }, + { name = 'DiagnosticSignInfo', text = ' ' }, + } + for _, sign in ipairs(diagnostic_signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name }) end - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim + vim.diagnostic.config { + virtual_text = { + prefix = '●', -- Could be '■', '▎', 'x' + }, + severity_sort = true, + float = { + source = 'always', -- Or "if_many" + }, + signs = true, + } end, }, + { -- Formatter + 'stevearc/conform.nvim', + config = function() + require('conform').setup { + formatters_by_ft = { + json = { { 'prettierd', 'prettier' } }, + lua = { 'stylua' }, + markdown = { 'prettier' }, + -- Conform will run multiple formatters sequentially + python = function(bufnr) + if require('conform').get_formatter_info('ruff_format', bufnr).available then + return { 'ruff_format' } + else + return { 'isort', 'black' } + end + end, + yaml = { 'prettier' }, + ['*'] = { 'injected' }, + }, + ignore_errors = true, + -- Map of treesitter language to file extension + -- A temporary file name with this extension will be generated during formatting + -- because some formatters care about the filename. + lang_to_ext = { + bash = 'sh', + latex = 'tex', + markdown = 'md', + python = 'py', + }, + } + -- + -- set up Format and f commands which should behave equivalently + vim.api.nvim_create_user_command('Format', function(args) + local range = nil + if args.count ~= -1 then + local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] + range = { + start = { args.line1, 0 }, + ['end'] = { args.line2, end_line:len() }, + } + end + require('conform').format { async = true, lsp_fallback = true, range = range } + end, { range = true }) + vim.keymap.set('', 'f', function() + require('conform').format { async = true, lsp_fallback = true } + end) + end, + }, + { + -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + 'hrsh7th/cmp-nvim-lsp', -- Adds LSP completion capabilities + 'hrsh7th/cmp-buffer', -- Source for buffer words + 'hrsh7th/cmp-path', -- Add source filesystem path + 'hrsh7th/cmp-cmdline', -- Source for vim's cmdline + }, + }, + { + 'rafamadriz/friendly-snippets', -- Snippets collection + config = function() + require('luasnip.loaders.from_vscode').lazy_load() - { -- Highlight, edit, and navigate code + require('luasnip/loaders/from_vscode').lazy_load { + paths = { + vim.fn.stdpath 'config' .. '/snippets', + }, + } + end, + }, + { + -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, build = ':TSUpdate', config = function() - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { enable = true }, - indent = { enable = true }, + -- [[ Configure Treesitter ]] + -- See `:help nvim-treesitter` + vim.defer_fn(function() + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { + 'bash', + 'c', + 'cpp', + 'csv', + 'dockerfile', + 'gitcommit', + 'gitignore', + 'go', + 'html', + 'json', + 'lua', + 'markdown', + 'markdown_inline', + 'python', + 'vim', + 'vimdoc', + 'xml', + 'yaml', + }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = false, + highlight = { + enable = true, + disable = function(lang, bufnr) -- Disable in large files + return vim.api.nvim_buf_line_count(bufnr) > 50000 + end, + additional_vim_regex_highlighting = false, + }, + indent = { enable = true, disable = { 'python', 'cpp' } }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, + } + end, 0) + + -- Configure highlight group for treesittercontext + vim.cmd [[ hi TreesitterContextBottom gui=underline guisp=#a6e3a1 ]] + end, + }, + -- INFO: Debug adapters + { + 'mfussenegger/nvim-dap', -- Enable debug adapters + dependencies = { + 'mfussenegger/nvim-dap-python', -- Python debug adapter + 'rcarriga/nvim-dap-ui', -- UI-like for debugging + 'theHamsta/nvim-dap-virtual-text', -- Inline text during debugging + 'nvim-neotest/nvim-nio', -- Needed by nvim-dap-ui + 'folke/neodev.nvim', -- Recommended by nvim-dap-ui + }, + config = function() + require('neodev').setup { + library = { plugins = { 'nvim-dap-ui' }, types = true }, + } + -- PERF: + -- =================================================== + -- UI related configurations + -- ==================================================== + local dap = require 'dap' + local sign = vim.fn.sign_define + + sign('DapBreakpoint', { text = ' ', texthl = 'DapBreakpoint', linehl = '', numhl = '' }) + sign('DapBreakpointCondition', { text = ' ', texthl = 'DapBreakpointCondition', linehl = '', numhl = '' }) + sign('DapLogPoint', { text = '◆ ', texthl = 'DapLogPoint', linehl = '', numhl = '' }) + sign('DapStoppedLine', { text = '󰁕 ', texthl = 'DapLogPoint', linehl = '', numhl = '' }) + sign('DapBreakpointRejected', { text = ' ', texthl = 'DapBreakpointRejected', linehl = '', numhl = '' }) + + -- PERF: + -- =================================================== + -- Adapters + -- ==================================================== + dap.adapters.codelldb = { + type = 'server', + port = '${port}', + executable = { + command = vim.fn.expand '$HOME/.local/share/nvim/mason/bin/codelldb', + args = { '--port', '${port}' }, + }, } + -- PERF: + -- =================================================== + -- Configurations + -- ==================================================== + dap.configurations.cpp = { + { + name = 'C++: Run file', + type = 'codelldb', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + }, + { + -- If you get an "Operation not permitted" error using this, try disabling YAMA: + -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope + name = 'C++: Attach to process', + type = 'codelldb', -- Adjust this to match your adapter name (`dap.adapters.`) + request = 'attach', + pid = require('dap.utils').pick_process, + args = {}, + }, + { + name = 'C++: ROS Node', + type = 'codelldb', + request = 'launch', + -- Might need to consider using vim.ui.input + program = function() + local pkgName = vim.fn.input('ROS Package: ', '') + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/install/' .. pkgName .. '/lib/' .. pkgName .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + }, + } + -- PERF: + -- ==================================================== + -- Extensions configurations + -- ==================================================== + require('dapui').setup { + controls = { + icons = { + pause = '⏸ ', + play = '▶ ', + terminate = '⏹ ', + }, + }, + floating = { + border = 'rounded', + }, + layouts = { + { + elements = { + { id = 'stacks', size = 0.30 }, + { id = 'breakpoints', size = 0.20 }, + { id = 'scopes', size = 0.50 }, + }, + position = 'left', + size = 40, + }, + { + elements = { + { id = 'console', size = 0.50 }, + { id = 'repl', size = 0.50 }, + }, + position = 'bottom', + size = 10, + }, + }, + } + require('nvim-dap-virtual-text').setup() + require('dap-python').setup() + table.insert(require('dap').configurations.python, { + type = 'python', + request = 'launch', + name = 'Python: ROS2 lauch test', + program = '/opt/ros/humble/bin/launch_test', + args = { '${file}' }, + }) - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + require('dap-python').test_runner = 'pytest' + + -- PERF: + -- ==================================================== + -- Custom User Commands for Dap + -- ==================================================== + vim.api.nvim_create_user_command('DapUIToggle', ":lua require('dapui').toggle()", {}) + vim.api.nvim_create_user_command('DapPytestMethod', ":lua require('dap-python').test_method()", {}) + + vim.api.nvim_create_user_command('DapResetUI', ":lua require('dapui').open({reset = true})", { desc = 'Reset DAP UI Layout' }) + + vim.api.nvim_create_user_command( + 'DapLogBreakpoint', + ":lua require('dap').set_breakpoint(nil, nil, vim.fn.input('Log Message: '))", + { desc = 'Set log message breakpoint' } + ) + vim.api.nvim_create_user_command( + 'DapConditionBreakpoint', + ":lua require('dap').set_breakpoint(vim.fn.input('Breakpoint Condition: '))", + { desc = 'Set conditional breakpoint' } + ) + vim.api.nvim_create_user_command( + 'DapConditionHitBreakpoint', + ":lua require('dap').set_breakpoint(vim.fn.input('Breapoint Condition: '), vim.fn.input('Hit Condition: '))", + { desc = 'Set condition and hit breakpoint' } + ) + vim.api.nvim_create_user_command( + 'DapHitBreakpoint', + ":lua require('dap').set_breakpoint(nil, vim.fn.input('Hit Condition: '))", + { desc = 'Set hit breakpoint' } + ) + + -- PERF: + -- ==================================================== + -- Configure DAP UI Listeners + -- ==================================================== + local dapui = require 'dapui' + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.dapui_config = function() + dapui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() + end + dap.listeners.before.exited.dapui_config = function() + dapui.close() + end end, }, - -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the - -- init.lua. If you want these files, they are in the repository, so you can just download them and - -- put them in the right spots if you want. + -- NOTE: Here you can add additional plugins that can enhance your Neovim Journey + { -- ROS2 related plugin + 'ErickKramer/nvim-ros2', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope.nvim', + 'nvim-treesitter/nvim-treesitter', + }, + opts = { + autocmds = true, + telescope = true, + treesitter = true, + }, + }, +}, {}) - -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for kickstart - -- - -- Here are some example plugins that I've included in the kickstart repository. - -- Uncomment any of the lines below to enable them (you will need to restart nvim). - -- - -- require 'kickstart.plugins.debug', - require 'kickstart.plugins.indent_line', +--[[INFO: Editor Settingss + -- Take the time to check the settings underneath and configure them base on your needs and preferences + --]] +-- Set highlight on search +vim.o.hlsearch = false - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` - -- This is the easiest way to modularize your config. - -- - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - { import = 'custom.plugins' }, -} +-- Make line numbers default +vim.opt.nu = true +vim.opt.relativenumber = true + +-- Enable mouse mode +vim.o.mouse = 'a' + +-- Enable break indent +vim.o.breakindent = true + +-- Save undo history +vim.o.undofile = true + +-- Case insensitive searching UNLESS /C or capital in search +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Decrease update time +vim.o.updatetime = 250 +vim.o.timeoutlen = 300 + +-- Configure how new splits should be opened +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- Preview substitutions live, as you type! +vim.opt.inccommand = 'split' + +-- Keep signcolumn on +vim.wo.signcolumn = 'yes' +vim.opt.signcolumn = 'yes:1' -- Enable expanding signcolumn + +-- Highlight current line +vim.opt.cursorline = true + +-- Render the column delimiter +vim.opt.colorcolumn = '100' + +-- Prefer spaces of 2 over tabs +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = true + +-- Render trailing spaces +vim.opt.listchars = { trail = '⇲', tab = '◦ ' } +vim.opt.list = true + +-- Share system clipboard +vim.opt.clipboard = 'unnamedplus' + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +-- set termguicolors to enable highlight groups +vim.opt.termguicolors = true + +-- Highlight on yank +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', +}) + +-- Relative line numbers +local numtogGrp = vim.api.nvim_create_augroup('NumberToggle', { clear = true }) +vim.api.nvim_create_autocmd({ 'BufEnter', 'InsertLeave', 'FocusGained' }, { + pattern = '*', + callback = function() + vim.opt.relativenumber = true + end, + group = numtogGrp, + desc = 'Turn on relative line numbering when the buffer is entered.', +}) +vim.api.nvim_create_autocmd({ 'BufLeave', 'InsertEnter', 'FocusLost' }, { + pattern = '*', + callback = function() + vim.opt.relativenumber = false + end, + group = numtogGrp, + desc = 'Turn off relative line numbering when the buffer is exited.', +}) + +--[[ INFO: Keymaps configurations +-- Make sure to change these keymaps so that they make the most sense to you +--]] + +-- Improve motions +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', 'n', 'nzzzv') +vim.keymap.set('n', 'N', 'Nzzzv') +vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move selected lines down' }) +vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move selected lines down' }) + +-- Improve splits navigation +vim.keymap.set('n', '', 'h') +vim.keymap.set('n', '', 'j') +vim.keymap.set('n', '', 'k') +vim.keymap.set('n', '', 'l') + +-- Improve pasting +vim.keymap.set('x', 'p', [["_dP]], { desc = 'Preserve previous word when pasting' }) + +vim.keymap.set('n', 'ya', ':%y+', { desc = 'Yank all content in file' }) + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open diagnostic in floating window' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Send diagnostic to loclist' }) +vim.keymap.set('n', 'dd', vim.diagnostic.disable, { desc = '[D]iagnostics [D]disable' }) +vim.keymap.set('n', 'de', vim.diagnostic.enable, { desc = '[D]iagnostics [E]nable' }) + +-- Change workingdir +vim.keymap.set('n', 'cw', ':cd %:p:h:pwd', { desc = 'Change current workding dir' }) +-- Fix forward jump after setting +-- https://github.com/neovim/neovim/issues/20126 +vim.keymap.set('n', '', '', { noremap = true }) + +-- Editor experience +vim.keymap.set('n', '', ':write', { desc = 'Save file' }) +vim.keymap.set('n', 'cd', ':ToggleAutoComplete', { desc = '[C]ompletion [D]isable' }) +vim.keymap.set('n', 'ce', ':ToggleAutoComplete', { desc = '[C]ompletion [E]nable' }) + +-- ==================================================== +-- Telescope +-- ==================================================== +vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + previewer = false, + sorting_strategy = 'ascending', + }) +end, { desc = '[/] Fuzzily search in current buffer]' }) + +vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', 'sp', require('telescope.builtin').spell_suggest, { desc = '[S][P]ell suggestion' }) +vim.keymap.set('n', 'sk', require('telescope.builtin').keymaps, { desc = '[S]earch [K]eymaps' }) +vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) +vim.keymap.set('n', 'sc', require('telescope.builtin').git_commits, { desc = '[S]earch git [C]ommits' }) +vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = 'Telescope [S]earch [R]esume' }) +-- Also possible to pass additional configuration options. +-- See `:help telescope.builtin.live_grep()` for information about particular keys +vim.keymap.set('n', 's/', function() + require('telescope.builtin').live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } +end, { desc = '[S]earch [/] in Open Files' }) +-- Shortcut for searching your neovim configuration files +vim.keymap.set('n', 'sn', function() + require('telescope.builtin').find_files { cwd = vim.fn.stdpath 'config' } +end, { desc = '[S]earch [N]eovim files' }) + +-- ==================================================== +-- Nvim Tree +-- ==================================================== +vim.keymap.set('n', 'ff', ':NvimTreeFindFile', { desc = 'NvimTree [F]ind [F]ile' }) +vim.keymap.set('n', 'tt', ':NvimTreeToggle', { desc = 'NvimTree [T]ree [T]oggle' }) + +-- ==================================================== +-- Execute over files +-- ==================================================== +vim.keymap.set('n', 'ru', ':w:!%:p', { desc = '[R][U]n current file' }) +vim.keymap.set('n', 'me', ':!chmod +x %:p', { desc = '[M]ake current file [E]xecutable' }) + +-- ==================================================== +-- Spectre +-- ==================================================== +vim.keymap.set('n', 'P', require('spectre').open, { desc = 'Open Search and Replace' }) + +-- ==================================================== +-- Trouble +-- ==================================================== +vim.keymap.set('n', 'xx', 'TroubleToggle', { silent = true, noremap = true, desc = 'Toggle trouble window' }) +vim.keymap.set( + 'n', + 'xw', + 'TroubleToggle workspace_diagnostics', + { silent = true, noremap = true, desc = 'Trouble diagnostics for the whole workspace' } +) +vim.keymap.set( + 'n', + 'xd', + 'TroubleToggle document_diagnostics', + { silent = true, noremap = true, desc = 'Trouble diagnostics for current document' } +) + +-- ==================================================== +-- Uncrustify +-- ==================================================== +vim.api.nvim_create_user_command( + 'Uncrustify', + -- ":!uncrustify -c /home/ekramer/evobot_ecosystem/humble_ws/ament_code_style.cfg --replace %:p -q --no-backup", {} + ':!ament_uncrustify --reformat %:p', + {} +) + +-- ==================================================== +-- Debugging -> dap +-- ==================================================== +vim.keymap.set('n', '', ":lua require('dapui').toggle()") +vim.keymap.set('n', 'dc', ":lua require('dap').continue()") +vim.keymap.set('n', 'do', ":lua require('dap').step_over()") +vim.keymap.set('n', 'di', ":lua require('dap').step_into()") +vim.keymap.set('n', 'dk', function() + require('dap.ui.widgets').hover() +end) +vim.keymap.set('n', 'd?', function() + local widgets = require 'dap.ui.widgets' + widgets.centered_float(widgets.scopes) +end) +vim.keymap.set('n', 'du', ":lua require('dap').step_out()") +vim.keymap.set('n', 'dl', ":lua require('dapui').float_element()", { silent = true, noremap = true, desc = 'Open floating window in Dap UI' }) +vim.keymap.set('n', 'dt', ":lua require('dap').toggle_breakpoint()", { silent = true, noremap = true, desc = 'Toggle breakpoint' }) +vim.keymap.set('n', 'dm', ":lua require('dap-python').test_method()", { silent = true, noremap = true, desc = 'DapPytest : Debug method' }) +vim.keymap.set('n', 'df', ":lua require('dap-python').test_class()", { silent = true, noremap = true, desc = 'DapPytest : Debug class' }) + +-- ==================================================== +-- barbar --> Tabs management +-- ==================================================== +vim.keymap.set('n', '', 'BufferPrevious', { silent = true, noremap = true, desc = 'Go to previous tab' }) +vim.keymap.set('n', '', 'BufferNext', { silent = true, noremap = true, desc = 'Go to next tab' }) +vim.keymap.set('n', '', 'BufferClose', { silent = true, noremap = true, desc = 'Close current buffer' }) +local opts = { noremap = true, silent = true } +-- Goto buffer in position... +vim.keymap.set('n', '', 'BufferGoto 1', opts) +vim.keymap.set('n', '', 'BufferGoto 2', opts) +vim.keymap.set('n', '', 'BufferGoto 3', opts) +vim.keymap.set('n', '', 'BufferGoto 4', opts) +vim.keymap.set('n', '', 'BufferGoto 5', opts) +vim.keymap.set('n', '', 'BufferGoto 6', opts) +vim.keymap.set('n', '', 'BufferGoto 7', opts) +vim.keymap.set('n', '', 'BufferGoto 8', opts) +vim.keymap.set('n', '', 'BufferGoto 9', opts) +vim.keymap.set('n', '', 'BufferLast', opts) + +-- ==================================================== +-- Quickfix +-- ==================================================== +vim.keymap.set('n', 'cn', ':cnext', { desc = 'Next quickfix list' }) +vim.keymap.set('n', 'cp', ':cprevious', { desc = 'Previous quickfix list' }) + +-- ==================================================== +-- Markdown +-- ==================================================== +vim.keymap.set('n', 'mp', ':MarkdownPreview', { desc = '[M]arkdown [P]review' }) + +-- ==================================================== +-- nvim-ros2 +-- ==================================================== +vim.keymap.set('n', 'li', ':Telescope ros2 interfaces', { desc = '[ROS 2]: List interfaces' }) +vim.keymap.set('n', 'ln', ':Telescope ros2 nodes', { desc = '[ROS 2]: List nodes' }) +vim.keymap.set('n', 'la', ':Telescope ros2 actions', { desc = '[ROS 2]: List actions' }) +vim.keymap.set('n', 'lt', ':Telescope ros2 topics', { desc = '[ROS 2]: List topics' }) +vim.keymap.set('n', 'ls', ':Telescope ros2 services', { desc = '[ROS 2]: List services' }) + +-- ==================================================== +-- git_coauthors +-- ==================================================== +vim.keymap.set('n', 'ga', ':Telescope coauthors', { desc = '[G]it co-[A]uthors' }) + +-- NOTE: Custon User Commads + +-- ==================================================== +-- ROS 2 related commands +-- ==================================================== +vim.api.nvim_command [[ + command! ColconBuild :! CC=clang CXX=clang++ colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON +]] +vim.api.nvim_command [[ + command! -nargs=1 ColconBuildSingle :! CC=clang CXX=clang++ colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --packages-up-to +]] +vim.api.nvim_command [[ + command! ColconBuildDebug :! CC=clang CXX=clang++ colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug +]] +vim.api.nvim_command [[ + command! -nargs=1 ColconBuildDebugSingle :! CC=clang CXX=clang++ colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug --packages-up-to +]] + +-- Test +vim.api.nvim_command [[ + command! ColconTest :! colcon test +]] +vim.api.nvim_command [[ + command! -nargs=1 ColconTestSingle :! colcon test --packages-select +]] +vim.api.nvim_command [[ + command! ColconTestResult :! colcon test-result --all +]] -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et @@ -948,3 +1659,9 @@ vim.api.nvim_create_autocmd('FileType', { vim.opt_local.expandtab = true end, }) + +-- Remap copy line +vim.api.nvim_set_keymap('n', 'Y', 'yy', { noremap = true, silent = true }) +-- Open Neo-tree automatically on startup +vim.cmd('Neotree show') +vim.api.nvim_set_keymap('i', '{', '{}', { noremap = true, silent = true }) From 5e6646168dd84452511ce387ad73e93890ace995 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Mon, 8 Dec 2025 22:29:34 -1000 Subject: [PATCH 12/22] fixed bugs --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index eb8456a0d7e..5dec1b61ecc 100644 --- a/init.lua +++ b/init.lua @@ -525,7 +525,7 @@ require('lazy').setup({ require('telescope').load_extension 'fzf' require('telescope').load_extension 'luasnip' require('telescope').load_extension 'live_grep_args' - require('telescope').load_extension 'coauthors' + -- require('telescope').load_extension 'coauthors' end, }, From 889544653795a341424bf11f2d4ea8db0eb729c6 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Mon, 8 Dec 2025 22:57:51 -1000 Subject: [PATCH 13/22] added editor split keybinds --- init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/init.lua b/init.lua index 5dec1b61ecc..08867b603d1 100644 --- a/init.lua +++ b/init.lua @@ -670,6 +670,7 @@ require('lazy').setup({ lua_ls = { settings = { Lua = { + diagnostics = { globals = { 'vim' } }, runtime = { version = 'LuaJIT' }, workspace = { checkThirdParty = false, @@ -1665,3 +1666,10 @@ vim.api.nvim_set_keymap('n', 'Y', 'yy', { noremap = true, silent = true }) -- Open Neo-tree automatically on startup vim.cmd('Neotree show') vim.api.nvim_set_keymap('i', '{', '{}', { noremap = true, silent = true }) + +vim.keymap.set("n", "", "wq") + +-- Quick splits +vim.keymap.set('n', 'sv', 'vsplit', { desc = 'Vertical split' }) +vim.keymap.set('n', 'sh', 'split', { desc = 'Horizontal split' }) + From 9fe1fed8e884ef4e789470e53df93cf728b1dccb Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Wed, 24 Dec 2025 00:16:51 -1000 Subject: [PATCH 14/22] neotree stuff, more similar to my zed workflow --- init.lua | 190 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 152 insertions(+), 38 deletions(-) diff --git a/init.lua b/init.lua index 08867b603d1..d2e25efe3ee 100644 --- a/init.lua +++ b/init.lua @@ -43,8 +43,23 @@ require('lazy').setup({ 'voldikss/vim-floaterm', 'tpope/vim-fugitive', -- Git wrapper for vim 'rhysd/conflict-marker.vim', -- weapon to fight against merge conflicts + { 'kylechui/nvim-surround', config = true }, { 'numToStr/Comment.nvim', opts = {} }, 'rhysd/git-messenger.vim', -- Shows commit message under cursor + { + 'jackMort/ChatGPT.nvim', + event = 'VeryLazy', + dependencies = { + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + 'nvim-telescope/telescope.nvim', + }, + config = function() + require('chatgpt').setup { + api_key_cmd = 'echo $OPENAI_API_KEY', + } + end, + }, { 'lewis6991/gitsigns.nvim', -- Similar to fugitive, but adds additiona functionality event = 'VeryLazy', @@ -74,7 +89,12 @@ require('lazy').setup({ 'nvim-telescope/telescope.nvim', }, }, - + { + 'windwp/nvim-autopairs', + config = function() + require('nvim-autopairs').setup {} + end, + }, -- INFO: Enhance Editor Experience { 'iamcco/markdown-preview.nvim', -- Markdown previewer @@ -124,14 +144,44 @@ require('lazy').setup({ }, 'mg979/vim-visual-multi', -- Enable multicursor { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information - } + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + }, + opts = { + filesystem = { + filtered_items = { + visible = false, -- fully hide + hide_dotfiles = true, + hide_gitignored = true, + + hide_by_name = { + '.git', + '.elc', + }, + + hide_by_pattern = { + '*.uid', -- ✅ correct + 'node_modules', + }, + }, + }, + }, + }, + { + 'akinsho/bufferline.nvim', + version = '*', + dependencies = 'nvim-tree/nvim-web-devicons', + opts = { + options = { + diagnostics = 'nvim_lsp', + show_buffer_close_icons = false, + show_close_icon = false, + }, + }, }, 'nvim-tree/nvim-web-devicons', -- Add fancy icons -- { @@ -167,22 +217,22 @@ require('lazy').setup({ ---@type Flash.Config opts = {}, keys = { - { - 's', - mode = { 'n', 'x', 'o' }, - function() - require('flash').jump() - end, - desc = 'Flash', - }, - { - 'S', - mode = { 'n', 'x', 'o' }, - function() - require('flash').treesitter() - end, - desc = 'Flash Treesitter', - }, + -- { + -- 's', + -- mode = { 'n', 'x', 'o' }, + -- function() + -- require('flash').jump() + -- end, + -- desc = 'Flash', + -- }, + -- { + -- 'S', + -- mode = { 'n', 'x', 'o' }, + -- function() + -- require('flash').treesitter() + -- end, + -- desc = 'Flash Treesitter', + -- }, { 'r', mode = 'o', @@ -247,7 +297,7 @@ require('lazy').setup({ require('lualine').setup { options = { icons_enabled = true, - theme = 'onedark', + theme = 'gruvbox-material', component_separators = '|', section_separators = '', ignore_focus = { @@ -481,6 +531,7 @@ require('lazy').setup({ 'nvim-telescope/telescope-live-grep-args.nvim', -- Enable passing arguments to ripgrep }, config = function() + local actions = require 'telescope.actions' require('telescope').setup { defaults = { prompt_prefix = '🔍 ', @@ -497,6 +548,18 @@ require('lazy').setup({ path_display = { truncate = 3, }, + mappings = { + i = { + [''] = actions.select_tab, -- open in new tab + [''] = actions.select_vertical, -- open in vsplit + [''] = actions.select_horizontal, -- open in split + }, + n = { + [''] = actions.select_tab, + [''] = actions.select_vertical, + [''] = actions.select_horizontal, + }, + }, }, pickers = { find_files = { @@ -670,7 +733,6 @@ require('lazy').setup({ lua_ls = { settings = { Lua = { - diagnostics = { globals = { 'vim' } }, runtime = { version = 'LuaJIT' }, workspace = { checkThirdParty = false, @@ -682,9 +744,17 @@ require('lazy').setup({ completion = { callSnippet = 'Replace', }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { + 'vim', + 'require', + }, + }, }, }, }, + rust_analyzer = {}, } -- PERF: @@ -966,9 +1036,9 @@ require('lazy').setup({ end require('conform').format { async = true, lsp_fallback = true, range = range } end, { range = true }) - vim.keymap.set('', 'f', function() + vim.keymap.set('', 'fa', function() require('conform').format { async = true, lsp_fallback = true } - end) + end, { desc = '[F]ormat [a]ll' }) end, }, { @@ -1028,6 +1098,8 @@ require('lazy').setup({ 'vimdoc', 'xml', 'yaml', + 'rust', -- add this if you want it for Rust + -- add any others: 'javascript', 'typescript', etc }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) @@ -1043,10 +1115,10 @@ require('lazy').setup({ incremental_selection = { enable = true, keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', + init_selection = '', + node_incremental = '', + -- scope_incremental = '', + node_decremental = '', }, }, textobjects = { @@ -1334,8 +1406,8 @@ vim.opt.cursorline = true vim.opt.colorcolumn = '100' -- Prefer spaces of 2 over tabs -vim.opt.tabstop = 2 -vim.opt.shiftwidth = 2 +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 vim.opt.expandtab = true -- Render trailing spaces @@ -1664,12 +1736,54 @@ vim.api.nvim_create_autocmd('FileType', { -- Remap copy line vim.api.nvim_set_keymap('n', 'Y', 'yy', { noremap = true, silent = true }) -- Open Neo-tree automatically on startup -vim.cmd('Neotree show') +-- vim.cmd 'Neotree show' vim.api.nvim_set_keymap('i', '{', '{}', { noremap = true, silent = true }) -vim.keymap.set("n", "", "wq") +vim.keymap.set('n', '', 'wqa') -- Quick splits vim.keymap.set('n', 'sv', 'vsplit', { desc = 'Vertical split' }) -vim.keymap.set('n', 'sh', 'split', { desc = 'Horizontal split' }) +vim.keymap.set('n', 'sh', 'split', { desc = 'Horizontal split' }) + +local ai_enabled = true + +-- AI toggle +local ai_enabled = true +vim.keymap.set('n', 'at', function() + ai_enabled = not ai_enabled + print(ai_enabled and 'AI enabled' or 'AI disabled') +end, { desc = 'Toggle AI' }) + +-- Safe wrapper +local function ai_safe(cmd) + return function() + if not ai_enabled then + print 'AI is disabled' + return + end + vim.cmd(cmd) + end +end + +-- Keymaps using safe wrapper +vim.keymap.set('n', 'ai', ai_safe 'ChatGPT', { desc = 'Open ChatGPT UI' }) +vim.keymap.set('v', 'ac', ai_safe 'ChatGPTEditWithInstruction', { desc = 'AI edit code' }) +vim.keymap.set('v', 'ae', ai_safe 'ChatGPTExplain', { desc = 'Explain code' }) + +-- creates a new tab +vim.keymap.set('n', 'tn', ':tabnew', { desc = 'New tab' }) +-- closes a tab +vim.keymap.set('n', 'tc', ':tabclose', { desc = 'Close tab' }) + +-- kills floaterms +vim.keymap.set('n', 'fk', ':FloatermKill!', { desc = 'Kill all floaterms' }) + +vim.keymap.set('x', 'S', '(nvim-surround-visual)', { remap = true }) + +-- delete by word with ctrl backspace +vim.keymap.set('i', '', '', { noremap = true }) +vim.keymap.set('c', '', '', { noremap = true }) +-- switch buffers quicker with shift+tab +vim.keymap.set('n', '', 'BufferLineCycleNext') +vim.keymap.set('n', '', 'BufferLineCyclePrev') From bb714228b25785b532e0c26716d16fa316040afa Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Tue, 30 Dec 2025 04:02:24 -1000 Subject: [PATCH 15/22] removed ros2 --- init.lua | 132 ++++++++++++++++--------------------------------------- 1 file changed, 38 insertions(+), 94 deletions(-) diff --git a/init.lua b/init.lua index d2e25efe3ee..3df29040bf6 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ ---[[ +--[[ini ===================================================================== ==================== READ THIS BEFORE CONTINUING ==================== ===================================================================== @@ -285,15 +285,6 @@ require('lazy').setup({ end end - local ros_distro = vim.fn.expand '$ROS_DISTRO' - - local function get_ros_distro() - if ros_distro and ros_distro ~= '$ROS_DISTRO' then - return '󰭆 ' .. ros_distro - else - return '' - end - end require('lualine').setup { options = { icons_enabled = true, @@ -314,7 +305,7 @@ require('lazy').setup({ lualine_a = { 'mode' }, lualine_b = { 'branch', 'diff', 'diagnostics' }, lualine_c = { 'filename' }, - lualine_x = { { get_venv }, { get_ros_distro }, 'fileformat', 'filetype' }, + lualine_x = { { get_venv }, 'fileformat', 'filetype' }, lualine_y = { 'progress' }, lualine_z = { 'location' }, }, @@ -404,6 +395,32 @@ require('lazy').setup({ } end, }, + { + 'WhoIsSethDaniel/mason-tool-installer.nvim', + dependencies = { 'williamboman/mason.nvim' }, + opts = { + ensure_installed = { + 'clangd', + 'clang-format', + 'codelldb', + 'cpplint', + 'cpptools', + 'csharpier', + 'csharp-language-server', + 'lua-language-server', + 'netcoredbg', + 'omnisharp', + 'omnisharp-mono', + 'prettier', + 'ruff', + 'rust-analyzer', + 'sonarlint-language-server', + 'stylua', + }, + auto_update = false, + run_on_start = true, + }, + }, { 'akinsho/toggleterm.nvim', -- Improve handling neovim terminals opts = {}, @@ -1115,10 +1132,10 @@ require('lazy').setup({ incremental_selection = { enable = true, keymaps = { - init_selection = '', - node_incremental = '', - -- scope_incremental = '', - node_decremental = '', + init_selection = '', + --node_incremental = '', + scope_incremental = '', + node_decremental = '', }, }, textobjects = { @@ -1212,7 +1229,6 @@ require('lazy').setup({ }, } -- PERF: - -- =================================================== -- Configurations -- ==================================================== dap.configurations.cpp = { @@ -1235,18 +1251,6 @@ require('lazy').setup({ pid = require('dap.utils').pick_process, args = {}, }, - { - name = 'C++: ROS Node', - type = 'codelldb', - request = 'launch', - -- Might need to consider using vim.ui.input - program = function() - local pkgName = vim.fn.input('ROS Package: ', '') - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/install/' .. pkgName .. '/lib/' .. pkgName .. '/', 'file') - end, - cwd = '${workspaceFolder}', - stopOnEntry = false, - }, } -- PERF: -- ==================================================== @@ -1285,13 +1289,6 @@ require('lazy').setup({ } require('nvim-dap-virtual-text').setup() require('dap-python').setup() - table.insert(require('dap').configurations.python, { - type = 'python', - request = 'launch', - name = 'Python: ROS2 lauch test', - program = '/opt/ros/humble/bin/launch_test', - args = { '${file}' }, - }) require('dap-python').test_runner = 'pytest' @@ -1344,21 +1341,6 @@ require('lazy').setup({ end end, }, - - -- NOTE: Here you can add additional plugins that can enhance your Neovim Journey - { -- ROS2 related plugin - 'ErickKramer/nvim-ros2', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope.nvim', - 'nvim-treesitter/nvim-treesitter', - }, - opts = { - autocmds = true, - telescope = true, - treesitter = true, - }, - }, }, {}) --[[INFO: Editor Settingss @@ -1568,15 +1550,6 @@ vim.keymap.set( { silent = true, noremap = true, desc = 'Trouble diagnostics for current document' } ) --- ==================================================== --- Uncrustify --- ==================================================== -vim.api.nvim_create_user_command( - 'Uncrustify', - -- ":!uncrustify -c /home/ekramer/evobot_ecosystem/humble_ws/ament_code_style.cfg --replace %:p -q --no-backup", {} - ':!ament_uncrustify --reformat %:p', - {} -) -- ==================================================== -- Debugging -> dap @@ -1628,15 +1601,6 @@ vim.keymap.set('n', 'cp', ':cprevious', { desc = 'Previous quickfix -- ==================================================== vim.keymap.set('n', 'mp', ':MarkdownPreview', { desc = '[M]arkdown [P]review' }) --- ==================================================== --- nvim-ros2 --- ==================================================== -vim.keymap.set('n', 'li', ':Telescope ros2 interfaces', { desc = '[ROS 2]: List interfaces' }) -vim.keymap.set('n', 'ln', ':Telescope ros2 nodes', { desc = '[ROS 2]: List nodes' }) -vim.keymap.set('n', 'la', ':Telescope ros2 actions', { desc = '[ROS 2]: List actions' }) -vim.keymap.set('n', 'lt', ':Telescope ros2 topics', { desc = '[ROS 2]: List topics' }) -vim.keymap.set('n', 'ls', ':Telescope ros2 services', { desc = '[ROS 2]: List services' }) - -- ==================================================== -- git_coauthors -- ==================================================== @@ -1644,32 +1608,6 @@ vim.keymap.set('n', 'ga', ':Telescope coauthors', { desc = '[G]it co -- NOTE: Custon User Commads --- ==================================================== --- ROS 2 related commands --- ==================================================== -vim.api.nvim_command [[ - command! ColconBuild :! CC=clang CXX=clang++ colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -]] -vim.api.nvim_command [[ - command! -nargs=1 ColconBuildSingle :! CC=clang CXX=clang++ colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --packages-up-to -]] -vim.api.nvim_command [[ - command! ColconBuildDebug :! CC=clang CXX=clang++ colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -]] -vim.api.nvim_command [[ - command! -nargs=1 ColconBuildDebugSingle :! CC=clang CXX=clang++ colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug --packages-up-to -]] - --- Test -vim.api.nvim_command [[ - command! ColconTest :! colcon test -]] -vim.api.nvim_command [[ - command! -nargs=1 ColconTestSingle :! colcon test --packages-select -]] -vim.api.nvim_command [[ - command! ColconTestResult :! colcon test-result --all -]] -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et @@ -1787,3 +1725,9 @@ vim.keymap.set('c', '', '', { noremap = true }) -- switch buffers quicker with shift+tab vim.keymap.set('n', '', 'BufferLineCycleNext') vim.keymap.set('n', '', 'BufferLineCyclePrev') + +vim.keymap.set("n", "is", ":TSNodeIncremental", { silent = true }) +vim.keymap.set("x", "is", ":TSNodeIncremental", { silent = true }) +vim.keymap.set("x", "ic", ":TSScopeIncremental", { silent = true }) +vim.keymap.set("x", "id", ":TSNodeDecremental", { silent = true }) + From 50462f568ecf92cc9919e437ea03cf168ef899fd Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Tue, 30 Dec 2025 21:36:50 -1000 Subject: [PATCH 16/22] removed ros2 stuff --- init.lua | 1081 ++++++++++++------------------------------------------ 1 file changed, 237 insertions(+), 844 deletions(-) diff --git a/init.lua b/init.lua index 3df29040bf6..2116ebccbf5 100644 --- a/init.lua +++ b/init.lua @@ -1,25 +1,9 @@ ---[[ini -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== - ros2-with-neovim is heavily inspired from Kickstart.nvim. - - I have basically taken the same approach of having a single file where all the - main configurations are done commenting clearly what all of them do. - - You should consider this as a starting point into your Neovim journey. Then, you can - start to add as many plugins and configurations as you see fit :). ---]] --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' --- Install package manager --- https://github.com/folke/lazy.nvim --- `:help lazy.nvim.txt` for more info --- INFO: There are different plugins manager for neovim. I prefer Lazy +-- ========================= +-- Lazy.nvim bootstrap +-- ========================= local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then vim.fn.system { @@ -27,25 +11,28 @@ if not vim.loop.fs_stat(lazypath) then 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', - '--branch=stable', -- latest stable release + '--branch=stable', lazypath, } end - vim.opt.rtp:prepend(lazypath) --- NOTE: Here is where you install your plugins. --- You can configure plugins using the `config` key. --- You can also configure plugins after the setup call, --- as they will be available in your neovim runtime. +-- ========================= +-- PLUGINS +-- ========================= require('lazy').setup({ - -- INFO: Git related plugins + -- Git 'voldikss/vim-floaterm', - 'tpope/vim-fugitive', -- Git wrapper for vim - 'rhysd/conflict-marker.vim', -- weapon to fight against merge conflicts + + 'tpope/vim-fugitive', + + 'rhysd/conflict-marker.vim', + { 'kylechui/nvim-surround', config = true }, + { 'numToStr/Comment.nvim', opts = {} }, - 'rhysd/git-messenger.vim', -- Shows commit message under cursor + + 'rhysd/git-messenger.vim', { 'jackMort/ChatGPT.nvim', event = 'VeryLazy', @@ -60,8 +47,9 @@ require('lazy').setup({ } end, }, + { - 'lewis6991/gitsigns.nvim', -- Similar to fugitive, but adds additiona functionality + 'lewis6991/gitsigns.nvim', event = 'VeryLazy', config = function() require('gitsigns').setup { @@ -76,65 +64,65 @@ require('lazy').setup({ } end, }, + { - 'sindrets/diffview.nvim', -- Single tabpage interface for easily cycling through diffs + 'sindrets/diffview.nvim', event = 'VeryLazy', - dependencies = { - 'nvim-lua/plenary.nvim', - }, + dependencies = { 'nvim-lua/plenary.nvim' }, }, - { -- Quick selection of co-authors + + { 'ErickKramer/git-coauthors.nvim', - dependencies = { - 'nvim-telescope/telescope.nvim', - }, + dependencies = { 'nvim-telescope/telescope.nvim' }, }, + + -- Editor UX { 'windwp/nvim-autopairs', config = function() require('nvim-autopairs').setup {} end, }, - -- INFO: Enhance Editor Experience + { - 'iamcco/markdown-preview.nvim', -- Markdown previewer - -- event = "VeryLazy", + 'iamcco/markdown-preview.nvim', build = function() vim.fn['mkdp#util#install']() end, config = function() - -- Refresh markdown when saving the buffer or leaving insert mode vim.g.mkdp_refresh_slow = 1 - - -- Fancy title vim.g.mkdp_page_title = '「${name}」' - - -- Dark mode (of course) vim.g.mkdp_theme = 'dark' - - -- Avoid auto close vim.g.mkdp_auto_close = 0 - vim.g.mkdp_combine_preview = 1 vim.g.mkdp_combine_preview_auto_refresh = 1 end, }, - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme` + + -- Colors + { 'folke/tokyonight.nvim', - lazy = false, -- make sure we load this during startup if it is your main colorscheme - priority = 1000, -- make sure to load this before all the other start plugins + lazy = false, + priority = 1000, config = function() - -- Load the colorscheme here vim.cmd.colorscheme 'gruvbox-material' - - -- You can configure highlights by doing something like vim.cmd.hi 'Comment gui=none' end, }, + + { + 'sphamba/smear-cursor.nvim', + opts = { -- Default Range + stiffness = 0.6, -- 0.6 [0, 1] + trailing_stiffness = 0.4, -- 0.45 [0, 1] + stiffness_insert_mode = 0.7, -- 0.5 [0, 1] + trailing_stiffness_insert_mode = 0.7, -- 0.5 [0, 1] + damping = 0.8, -- 0.85 [0, 1] + damping_insert_mode = 0.8, -- 0.9 [0, 1] + distance_stop_animating = 0.1, -- 0.1 > 0 + }, + }, + { 'f4z3r/gruvbox-material.nvim', name = 'gruvbox-material', @@ -142,7 +130,10 @@ require('lazy').setup({ priority = 1000, opts = {}, }, - 'mg979/vim-visual-multi', -- Enable multicursor + + 'mg979/vim-visual-multi', + + -- File tree { 'nvim-neo-tree/neo-tree.nvim', branch = 'v3.x', @@ -154,23 +145,17 @@ require('lazy').setup({ opts = { filesystem = { filtered_items = { - visible = false, -- fully hide + visible = false, hide_dotfiles = true, hide_gitignored = true, - - hide_by_name = { - '.git', - '.elc', - }, - - hide_by_pattern = { - '*.uid', -- ✅ correct - 'node_modules', - }, + hide_by_name = { '.git', '.elc' }, + hide_by_pattern = { '*.uid', 'node_modules' }, }, }, }, }, + + -- Buffers/tabs { 'akinsho/bufferline.nvim', version = '*', @@ -183,56 +168,20 @@ require('lazy').setup({ }, }, }, - 'nvim-tree/nvim-web-devicons', -- Add fancy icons - -- { - -- 'nvim-tree/nvim-tree.lua', -- File tree - -- config = function() - -- -- Config needed for nvim-tree - -- vim.g.loaded_netrw = 1 - -- vim.g.loaded_netrwPlugin = 1 - -- require('nvim-tree').setup { - -- sort_by = 'case_sensitive', - -- view = { - -- adaptive_size = false, - -- relativenumber = true, - -- width = 40, - -- }, - -- renderer = { - -- group_empty = true, - -- }, - -- filters = { - -- dotfiles = true, - -- }, - -- } - -- end, - -- }, + 'nvim-tree/nvim-web-devicons', + { - 'folke/todo-comments.nvim', -- Fancy TODOs/FIXMEs + 'folke/todo-comments.nvim', dependencies = 'nvim-lua/plenary.nvim', opts = {}, }, - { -- Improve file navigation with search labels + + -- Flash (treesitter features removed) + { 'folke/flash.nvim', event = 'VeryLazy', - ---@type Flash.Config opts = {}, keys = { - -- { - -- 's', - -- mode = { 'n', 'x', 'o' }, - -- function() - -- require('flash').jump() - -- end, - -- desc = 'Flash', - -- }, - -- { - -- 'S', - -- mode = { 'n', 'x', 'o' }, - -- function() - -- require('flash').treesitter() - -- end, - -- desc = 'Flash Treesitter', - -- }, { 'r', mode = 'o', @@ -241,24 +190,16 @@ require('lazy').setup({ end, desc = 'Remote Flash', }, - { - 'R', - mode = { 'o', 'x' }, - function() - require('flash').treesitter_search() - end, - desc = 'Treesitter Search', - }, - -- { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, + -- NOTE: removed: flash.treesitter(), flash.treesitter_search() }, }, + { - 'folke/trouble.nvim', -- Quickfix list for LSP errors + 'folke/trouble.nvim', dependencies = 'nvim-tree/nvim-web-devicons', config = function() require('trouble').setup { signs = { - -- icons / text used for a diagnostic error = '', warning = '', hint = '', @@ -268,21 +209,19 @@ require('lazy').setup({ } end, }, + + { 'folke/which-key.nvim', opts = {} }, + { - 'folke/which-key.nvim', -- Popup with possible keybindings of the command you started to type - opts = {}, - }, - { - 'nvim-lualine/lualine.nvim', -- Fancier statusline + 'nvim-lualine/lualine.nvim', config = function() local function get_venv() local venv = vim.env.VIRTUAL_ENV if venv then local env = string.match(venv, '[^/]+$') return ' ' .. env - else - return '' end + return '' end require('lualine').setup { @@ -312,46 +251,11 @@ require('lazy').setup({ } end, }, - { - 'nvim-pack/nvim-spectre', -- Advance Search and Replace - opts = {}, - }, - { - 'goolord/alpha-nvim', -- Greeter dashboard - dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function() - local alpha = require 'alpha' - local dashboard = require 'alpha.themes.dashboard' - dashboard.section.header.val = { - [[██████╗ ██████╗ ███████╗]], - [[██╔══██╗██╔═══██╗██╔════╝]], - [[██████╔╝██║ ██║███████╗]], - [[██╔══██╗██║ ██║╚════██║]], - [[██║ ██║╚██████╔╝███████║]], - [[╚═╝ ╚═╝ ╚═════╝ ╚══════╝]], - } - dashboard.section.buttons.val = { - dashboard.button('f', ' Find file', ':Telescope find_files '), - dashboard.button('t', ' Find text', ':Telescope live_grep '), - dashboard.button('n', ' New file', ':ene startinsert '), - dashboard.button('c', ' Configuration', ':e ~/.config/nvim/init.lua '), - dashboard.button('u', ' Update plugins', ':Lazy sync'), - dashboard.button('q', ' Quit', ':qa'), - } - local handle = io.popen 'fortune' - local fortune = handle:read '*a' - handle:close() - dashboard.section.footer.val = fortune - dashboard.config.opts.noautocmd = true + { 'nvim-pack/nvim-spectre', opts = {} }, - vim.cmd [[autocmd User AlphaReady echo 'ready']] - - alpha.setup(dashboard.config) - end, - }, { - 'romgrk/barbar.nvim', -- Tabline plugin that improves buffers and tabs + 'romgrk/barbar.nvim', event = 'BufEnter', dependencies = 'nvim-tree/nvim-web-devicons', init = function() @@ -359,11 +263,9 @@ require('lazy').setup({ end, lazy = true, }, + { - -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help indent_blankline.txt` main = 'ibl', opts = {}, config = function() @@ -378,8 +280,6 @@ require('lazy').setup({ } local hooks = require 'ibl.hooks' - -- create the highlight groups in the highlight setup hook, so they are reset - -- every time the colorscheme changes hooks.register(hooks.type.HIGHLIGHT_SETUP, function() vim.api.nvim_set_hl(0, 'RainbowRed', { fg = '#E06C75' }) vim.api.nvim_set_hl(0, 'RainbowYellow', { fg = '#E5C07B' }) @@ -389,12 +289,15 @@ require('lazy').setup({ vim.api.nvim_set_hl(0, 'RainbowViolet', { fg = '#C678DD' }) vim.api.nvim_set_hl(0, 'RainbowCyan', { fg = '#56B6C2' }) end) + require('ibl').setup { indent = { highlight = highlight, char = '┊' }, scope = { enabled = false }, } end, }, + + -- Tooling installer { 'WhoIsSethDaniel/mason-tool-installer.nvim', dependencies = { 'williamboman/mason.nvim' }, @@ -421,8 +324,10 @@ require('lazy').setup({ run_on_start = true, }, }, + + -- Terminal UX { - 'akinsho/toggleterm.nvim', -- Improve handling neovim terminals + 'akinsho/toggleterm.nvim', opts = {}, config = function() require('toggleterm').setup { @@ -441,21 +346,15 @@ require('lazy').setup({ float_opts = { border = 'curved', winblend = 0, - highlights = { - border = 'Normal', - background = 'Normal', - }, + highlights = { border = 'Normal', background = 'Normal' }, }, } + function _G.set_terminal_keymaps() local opts = { noremap = true } vim.diagnostic.disable(0) vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) end - - -- ==================================================== - -- Custom terminals - -- ==================================================== vim.cmd 'autocmd! TermOpen term://* lua set_terminal_keymaps()' local Terminal = require('toggleterm.terminal').Terminal @@ -464,10 +363,7 @@ require('lazy').setup({ cmd = 'lazygit', hidden = true, direction = 'float', - float_opts = { -- Get floating window in full screen - width = vim.o.columns, - height = vim.o.lines, - }, + float_opts = { width = vim.o.columns, height = vim.o.lines }, on_open = function(term) vim.cmd 'startinsert!' vim.diagnostic.disable(0) @@ -478,9 +374,8 @@ require('lazy').setup({ end, } - function _lazygit_toggle() - -- lazygit.dir = vim.fn.getcwd() -- Open lazygit in the current working directory - lazygit.dir = vim.fn.expand '%:p:h' -- Open lazygit in the repository from the file + function _G._lazygit_toggle() + lazygit.dir = vim.fn.expand '%:p:h' lazygit:toggle() end @@ -490,16 +385,15 @@ require('lazy').setup({ hidden = true, hidden_numbers = true, } - - function _python_toggle() + function _G._python_toggle() python:toggle() end - -- Fancy terminals vim.api.nvim_set_keymap('n', 'lg', 'lua _lazygit_toggle()', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', 'ip', 'lua _python_toggle()', { noremap = true, silent = true }) end, }, + { 'stevearc/dressing.nvim', opts = {}, @@ -509,9 +403,7 @@ require('lazy').setup({ get_config = function() return { title_pos = 'center', - win_options = { - sidescrolloff = 10, - }, + win_options = { sidescrolloff = 10 }, insert_only = false, } end, @@ -519,33 +411,24 @@ require('lazy').setup({ } end, }, - { -- Color theme - 'navarasu/onedark.nvim', - priority = 1000, - -- config = function() - -- vim.cmd.colorscheme 'onedark' - -- end, - }, - -- Fuzzy Finder (files, lsp, etc) + + { 'navarasu/onedark.nvim', priority = 1000 }, + + -- Telescope { 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim', - -- Fuzzy Finder Algorithm which requires local dependencies to be built. - -- Only load if `make` is available. Make sure you have the system - -- requirements installed. { 'nvim-telescope/telescope-fzf-native.nvim', - -- NOTE: If you are having trouble with this installation, - -- refer to the README for telescope-fzf-native for more instructions. build = 'make', cond = function() return vim.fn.executable 'make' == 1 end, }, - 'benfowler/telescope-luasnip.nvim', -- Allows to search the available snippet - 'nvim-telescope/telescope-live-grep-args.nvim', -- Enable passing arguments to ripgrep + 'benfowler/telescope-luasnip.nvim', + 'nvim-telescope/telescope-live-grep-args.nvim', }, config = function() local actions = require 'telescope.actions' @@ -562,14 +445,12 @@ require('lazy').setup({ '--smart-case', '--follow', }, - path_display = { - truncate = 3, - }, + path_display = { truncate = 3 }, mappings = { i = { - [''] = actions.select_tab, -- open in new tab - [''] = actions.select_vertical, -- open in vsplit - [''] = actions.select_horizontal, -- open in split + [''] = actions.select_tab, + [''] = actions.select_vertical, + [''] = actions.select_horizontal, }, n = { [''] = actions.select_tab, @@ -580,65 +461,48 @@ require('lazy').setup({ }, pickers = { find_files = { - find_command = { - 'rg', - '--files', - '--hidden', - '-g', - '!.git', - }, + find_command = { 'rg', '--files', '--hidden', '-g', '!.git' }, follow = true, }, - lsp_document_symbols = { - show_line = true, - }, + lsp_document_symbols = { show_line = true }, }, extensions = { fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = 'smart_case', -- or "ignore_case" or "respect_case" + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', }, }, } require('telescope').load_extension 'fzf' require('telescope').load_extension 'luasnip' require('telescope').load_extension 'live_grep_args' - -- require('telescope').load_extension 'coauthors' end, }, - -- - -- NOTE: This is where your plugins related to LSP can be installed. - -- The configuration is done below. Search for lspconfig to find it below. + -- LSP { - -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { - -- Automatically install LSPs to stdpath for neovim { 'williamboman/mason.nvim', config = true }, 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP { 'j-hui/fidget.nvim', config = function() require('fidget').setup { - -- Options related to notification subsystem notification = { - -- Options related to the notification window and buffer window = { - normal_hl = 'Comment', -- Base highlight group in the notification window - border = 'rounded', -- Border around the notification window - zindex = 45, -- Stacking priority of the notification window - max_width = 0, -- Maximum width of the notification window - max_height = 0, -- Maximum height of the notification window - x_padding = 1, -- Padding from right edge of window boundary - y_padding = 0, -- Padding from bottom edge of window boundary - align = 'bottom', -- How to align the notification window - relative = 'editor', -- What the notification window position is relative to + normal_hl = 'Comment', + border = 'rounded', + zindex = 45, + max_width = 0, + max_height = 0, + x_padding = 1, + y_padding = 0, + align = 'bottom', + relative = 'editor', }, }, } @@ -646,70 +510,29 @@ require('lazy').setup({ }, }, config = function() - -- INFO: LSP Settings - -- This contains the configuration of several components related to LSPs - -- - luasnip - -- - mason - -- - mason-lspconfig - -- - nvim-cmp - -- - nvim-lspconfig - - -- PERF: - -- ==================================================== - -- LSP Keymaps - -- ==================================================== - - -- This function gets run when an LSP connects to a particular buffer. vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('personal-lsp-attach', { clear = true }), callback = function(event) - -- Create a wrapper function to simplify keymaps creation local map = function(keys, func, desc) vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - -- Find references for the word under your cursor. map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - -- Fuzzy find all the symbols in your current workspace - -- Similar to document symbols, except searches over your whole project. map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- Rename the variable under your cursor - -- Most Language Servers support renaming across files, etc. map('rn', vim.lsp.buf.rename, '[R]e[n]ame') - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - - -- Opens a popup that displays documentation about the word under your cursor - -- See `:help K` for why this keymap map('K', vim.lsp.buf.hover, 'Hover Documentation') map('', vim.lsp.buf.signature_help, 'Signature Documentation') - -- NOTE: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header - -- 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.server_capabilities.documentHighlightProvider then vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, callback = vim.lsp.buf.document_highlight, }) - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { buffer = event.buf, callback = vim.lsp.buf.clear_references, @@ -718,19 +541,11 @@ require('lazy').setup({ end, }) - -- PERF: - -- ==================================================== - -- LSP Servers - -- ==================================================== local servers = { clangd = { cmd = { - -- see clangd --help-hidden 'clangd', '--background-index', - -- by default, clang-tidy use -checks=clang-diagnostic-*,clang-analyzer-* - -- to add more checks, create .clang-tidy file in the root directory - -- and add Checks key, see https://clang.llvm.org/extra/clang-tidy/ '--clang-tidy', '--completion-style=bundled', '--cross-file-rename', @@ -753,124 +568,51 @@ require('lazy').setup({ runtime = { version = 'LuaJIT' }, workspace = { checkThirdParty = false, - library = { - '${3rd}/luv/library', - unpack(vim.api.nvim_get_runtime_file('', true)), - }, - }, - completion = { - callSnippet = 'Replace', - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { - 'vim', - 'require', - }, + library = { '${3rd}/luv/library', unpack(vim.api.nvim_get_runtime_file('', true)) }, }, + completion = { callSnippet = 'Replace' }, + diagnostics = { globals = { 'vim', 'require' } }, }, }, }, rust_analyzer = {}, } - -- PERF: - -- ==================================================== - -- capabilities Configuratioon - -- ==================================================== - - -- nvim-cmp supports additional completion capabilities, so broadcast that to servers local capabilities = vim.lsp.protocol.make_client_capabilities() - -- capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = false capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) capabilities.offsetEncoding = { 'utf-16' } capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true } - -- Enable folding (for nvim-ufo) - capabilities.textDocument.foldingRange = { - dynamicRegistration = false, - lineFoldingOnly = true, - } - - -- PERF: - -- ==================================================== - -- Mason Configuratioon - -- ==================================================== - - -- Setup mason so it can manage external tooling - require('mason').setup { - ui = { - border = 'rounded', - }, - } - - -- mason-lspconfig configurations + require('mason').setup { ui = { border = 'rounded' } } require('mason-lspconfig').setup { handlers = { function(server_name) local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for tsserver) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) require('lspconfig')[server_name].setup(server) end, }, } - require('mason-tool-installer').setup { - -- List of all DAP, Linter and Formatters to install + require('mason-tool-installer').setup { ensure_installed = { - -- LSPs 'clangd', 'lua_ls', 'pyright', 'ruff', - - -- DAP 'codelldb', 'cpptools', - - -- Linter 'cpplint', - - -- Formatters 'stylua', 'prettier', }, - - -- if set to true this will check each tool for updates. If updates - -- are available the tool will be updated. This setting does not - -- affect :MasonToolsUpdate or :MasonToolsInstall. - -- Default: false auto_update = false, - - -- automatically install / update on startup. If set to false nothing - -- will happen on startup. You can use :MasonToolsInstall or - -- :MasonToolsUpdate to install tools and check for updates. - -- Default: true run_on_start = true, - - -- set a delay (in ms) before the installation starts. This is only - -- effective if run_on_start is set to true. - -- e.g.: 5000 = 5 second delay, 10000 = 10 second delay, etc... - -- Default: 0 - start_delay = 3000, -- 3 second delay - - -- Only attempt to install if 'debounce_hours' number of hours has - -- elapsed since the last time Neovim was started. This stores a - -- timestamp in a file named stdpath('data')/mason-tool-installer-debounce. - -- This is only relevant when you are using 'run_on_start'. It has no - -- effect when running manually via ':MasonToolsInstall' etc.... - -- Default: nil - debounce_hours = 5, -- at least 5 hours between attempts to install/update + start_delay = 3000, + debounce_hours = 5, } - -- PERF: - -- ==================================================== - -- nvim-cmp configuration - -- ==================================================== - local cmp = require 'cmp' local luasnip = require 'luasnip' @@ -880,9 +622,6 @@ require('lazy').setup({ luasnip.lsp_expand(args.body) end, }, - -- performance = { - -- max_view_entries = 20, - -- }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), @@ -890,10 +629,7 @@ require('lazy').setup({ [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, + [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() @@ -925,9 +661,7 @@ require('lazy').setup({ }, } - -- Suggested approach to cancel snippet session after going back to normal mode - -- Taken from https://github.com/L3MON4D3/LuaSnip/issues/258#issuecomment-1011938524 - function leave_snippet() + function _G.leave_snippet() if ((vim.v.event.old_mode == 's' and vim.v.event.new_mode == 'n') or vim.v.event.old_mode == 'i') and require('luasnip').session.current_nodes[vim.api.nvim_get_current_buf()] @@ -936,11 +670,8 @@ require('lazy').setup({ require('luasnip').unlink_current() end end - - -- stop snippets when you leave to normal mode vim.api.nvim_command [[ autocmd ModeChanged * lua leave_snippet() ]] - -- Custom command to disable completion local cmp_enabled = true vim.api.nvim_create_user_command('ToggleAutoComplete', function() if cmp_enabled then @@ -952,42 +683,21 @@ require('lazy').setup({ end end, {}) - -- Configure cmp-cmdline cmp.setup.cmdline('/', { mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' }, - }, + sources = { { name = 'buffer' } }, }) - -- `:` cmdline setup. cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' }, - }, { - { - name = 'cmdline', - option = { - ignore_cmds = { 'Man', '!' }, - }, - }, + sources = cmp.config.sources({ { name = 'path' } }, { + { name = 'cmdline', option = { ignore_cmds = { 'Man', '!' } } }, }), }) - -- PERF: - -- ==================================================== - -- LSP related UI Configurations - -- ==================================================== - - -- Add bordered to LSP info require('lspconfig.ui.windows').default_options.border = 'rounded' - - -- INFO: Configure LSP textDocuments vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' }) - vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded' }) - -- Diagnostic signs local diagnostic_signs = { { name = 'DiagnosticSignError', text = ' ' }, { name = 'DiagnosticSignWarn', text = ' ' }, @@ -999,18 +709,16 @@ require('lazy').setup({ end vim.diagnostic.config { - virtual_text = { - prefix = '●', -- Could be '■', '▎', 'x' - }, + virtual_text = { prefix = '●' }, severity_sort = true, - float = { - source = 'always', -- Or "if_many" - }, + float = { source = 'always' }, signs = true, } end, }, - { -- Formatter + + -- Formatter + { 'stevearc/conform.nvim', config = function() require('conform').setup { @@ -1018,21 +726,17 @@ require('lazy').setup({ json = { { 'prettierd', 'prettier' } }, lua = { 'stylua' }, markdown = { 'prettier' }, - -- Conform will run multiple formatters sequentially python = function(bufnr) if require('conform').get_formatter_info('ruff_format', bufnr).available then return { 'ruff_format' } - else - return { 'isort', 'black' } end + return { 'isort', 'black' } end, yaml = { 'prettier' }, ['*'] = { 'injected' }, }, ignore_errors = true, - -- Map of treesitter language to file extension - -- A temporary file name with this extension will be generated during formatting - -- because some formatters care about the filename. + -- NOTE: removed treesitter mapping; keep only what you need lang_to_ext = { bash = 'sh', latex = 'tex', @@ -1040,8 +744,7 @@ require('lazy').setup({ python = 'py', }, } - -- - -- set up Format and f commands which should behave equivalently + vim.api.nvim_create_user_command('Format', function(args) local range = nil if args.count ~= -1 then @@ -1053,160 +756,48 @@ require('lazy').setup({ end require('conform').format { async = true, lsp_fallback = true, range = range } end, { range = true }) + vim.keymap.set('', 'fa', function() require('conform').format { async = true, lsp_fallback = true } end, { desc = '[F]ormat [a]ll' }) end, }, + + -- Completion { - -- Autocompletion 'hrsh7th/nvim-cmp', dependencies = { - -- Snippet Engine & its associated nvim-cmp source 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', - 'hrsh7th/cmp-nvim-lsp', -- Adds LSP completion capabilities - 'hrsh7th/cmp-buffer', -- Source for buffer words - 'hrsh7th/cmp-path', -- Add source filesystem path - 'hrsh7th/cmp-cmdline', -- Source for vim's cmdline + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', }, }, { - 'rafamadriz/friendly-snippets', -- Snippets collection + 'rafamadriz/friendly-snippets', config = function() require('luasnip.loaders.from_vscode').lazy_load() - require('luasnip/loaders/from_vscode').lazy_load { - paths = { - vim.fn.stdpath 'config' .. '/snippets', - }, + paths = { vim.fn.stdpath 'config' .. '/snippets' }, } end, }, - { - -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, - build = ':TSUpdate', - config = function() - -- [[ Configure Treesitter ]] - -- See `:help nvim-treesitter` - vim.defer_fn(function() - require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { - 'bash', - 'c', - 'cpp', - 'csv', - 'dockerfile', - 'gitcommit', - 'gitignore', - 'go', - 'html', - 'json', - 'lua', - 'markdown', - 'markdown_inline', - 'python', - 'vim', - 'vimdoc', - 'xml', - 'yaml', - 'rust', -- add this if you want it for Rust - -- add any others: 'javascript', 'typescript', etc - }, - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, - highlight = { - enable = true, - disable = function(lang, bufnr) -- Disable in large files - return vim.api.nvim_buf_line_count(bufnr) > 50000 - end, - additional_vim_regex_highlighting = false, - }, - indent = { enable = true, disable = { 'python', 'cpp' } }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - --node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, - } - end, 0) - - -- Configure highlight group for treesittercontext - vim.cmd [[ hi TreesitterContextBottom gui=underline guisp=#a6e3a1 ]] - end, - }, - -- INFO: Debug adapters + -- DAP { - 'mfussenegger/nvim-dap', -- Enable debug adapters + 'mfussenegger/nvim-dap', dependencies = { - 'mfussenegger/nvim-dap-python', -- Python debug adapter - 'rcarriga/nvim-dap-ui', -- UI-like for debugging - 'theHamsta/nvim-dap-virtual-text', -- Inline text during debugging - 'nvim-neotest/nvim-nio', -- Needed by nvim-dap-ui - 'folke/neodev.nvim', -- Recommended by nvim-dap-ui + 'mfussenegger/nvim-dap-python', + 'rcarriga/nvim-dap-ui', + 'theHamsta/nvim-dap-virtual-text', + 'nvim-neotest/nvim-nio', + 'folke/neodev.nvim', }, config = function() - require('neodev').setup { - library = { plugins = { 'nvim-dap-ui' }, types = true }, - } - -- PERF: - -- =================================================== - -- UI related configurations - -- ==================================================== + require('neodev').setup { library = { plugins = { 'nvim-dap-ui' }, types = true } } + local dap = require 'dap' local sign = vim.fn.sign_define @@ -1216,10 +807,6 @@ require('lazy').setup({ sign('DapStoppedLine', { text = '󰁕 ', texthl = 'DapLogPoint', linehl = '', numhl = '' }) sign('DapBreakpointRejected', { text = ' ', texthl = 'DapBreakpointRejected', linehl = '', numhl = '' }) - -- PERF: - -- =================================================== - -- Adapters - -- ==================================================== dap.adapters.codelldb = { type = 'server', port = '${port}', @@ -1228,9 +815,7 @@ require('lazy').setup({ args = { '--port', '${port}' }, }, } - -- PERF: - -- Configurations - -- ==================================================== + dap.configurations.cpp = { { name = 'C++: Run file', @@ -1243,30 +828,17 @@ require('lazy').setup({ stopOnEntry = false, }, { - -- If you get an "Operation not permitted" error using this, try disabling YAMA: - -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope name = 'C++: Attach to process', - type = 'codelldb', -- Adjust this to match your adapter name (`dap.adapters.`) + type = 'codelldb', request = 'attach', pid = require('dap.utils').pick_process, args = {}, }, } - -- PERF: - -- ==================================================== - -- Extensions configurations - -- ==================================================== + require('dapui').setup { - controls = { - icons = { - pause = '⏸ ', - play = '▶ ', - terminate = '⏹ ', - }, - }, - floating = { - border = 'rounded', - }, + controls = { icons = { pause = '⏸ ', play = '▶ ', terminate = '⏹ ' } }, + floating = { border = 'rounded' }, layouts = { { elements = { @@ -1278,138 +850,55 @@ require('lazy').setup({ size = 40, }, { - elements = { - { id = 'console', size = 0.50 }, - { id = 'repl', size = 0.50 }, - }, + elements = { { id = 'console', size = 0.50 }, { id = 'repl', size = 0.50 } }, position = 'bottom', size = 10, }, }, } + require('nvim-dap-virtual-text').setup() require('dap-python').setup() - require('dap-python').test_runner = 'pytest' - -- PERF: - -- ==================================================== - -- Custom User Commands for Dap - -- ==================================================== vim.api.nvim_create_user_command('DapUIToggle', ":lua require('dapui').toggle()", {}) vim.api.nvim_create_user_command('DapPytestMethod', ":lua require('dap-python').test_method()", {}) - vim.api.nvim_create_user_command('DapResetUI', ":lua require('dapui').open({reset = true})", { desc = 'Reset DAP UI Layout' }) - - vim.api.nvim_create_user_command( - 'DapLogBreakpoint', - ":lua require('dap').set_breakpoint(nil, nil, vim.fn.input('Log Message: '))", - { desc = 'Set log message breakpoint' } - ) - vim.api.nvim_create_user_command( - 'DapConditionBreakpoint', - ":lua require('dap').set_breakpoint(vim.fn.input('Breakpoint Condition: '))", - { desc = 'Set conditional breakpoint' } - ) - vim.api.nvim_create_user_command( - 'DapConditionHitBreakpoint', - ":lua require('dap').set_breakpoint(vim.fn.input('Breapoint Condition: '), vim.fn.input('Hit Condition: '))", - { desc = 'Set condition and hit breakpoint' } - ) - vim.api.nvim_create_user_command( - 'DapHitBreakpoint', - ":lua require('dap').set_breakpoint(nil, vim.fn.input('Hit Condition: '))", - { desc = 'Set hit breakpoint' } - ) - - -- PERF: - -- ==================================================== - -- Configure DAP UI Listeners - -- ==================================================== - local dapui = require 'dapui' - dap.listeners.before.attach.dapui_config = function() - dapui.open() - end - dap.listeners.before.launch.dapui_config = function() - dapui.open() - end - dap.listeners.before.event_terminated.dapui_config = function() - dapui.close() - end - dap.listeners.before.exited.dapui_config = function() - dapui.close() - end end, }, }, {}) ---[[INFO: Editor Settingss - -- Take the time to check the settings underneath and configure them base on your needs and preferences - --]] --- Set highlight on search +-- ========================= +-- Editor settings +-- ========================= vim.o.hlsearch = false - --- Make line numbers default vim.opt.nu = true vim.opt.relativenumber = true - --- Enable mouse mode vim.o.mouse = 'a' - --- Enable break indent vim.o.breakindent = true - --- Save undo history vim.o.undofile = true - --- Case insensitive searching UNLESS /C or capital in search vim.o.ignorecase = true vim.o.smartcase = true - --- Decrease update time vim.o.updatetime = 250 vim.o.timeoutlen = 300 - --- Configure how new splits should be opened vim.opt.splitright = true vim.opt.splitbelow = true - --- Preview substitutions live, as you type! vim.opt.inccommand = 'split' - --- Keep signcolumn on vim.wo.signcolumn = 'yes' -vim.opt.signcolumn = 'yes:1' -- Enable expanding signcolumn - --- Highlight current line +vim.opt.signcolumn = 'yes:1' vim.opt.cursorline = true - --- Render the column delimiter vim.opt.colorcolumn = '100' - --- Prefer spaces of 2 over tabs vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.expandtab = true - --- Render trailing spaces vim.opt.listchars = { trail = '⇲', tab = '◦ ' } vim.opt.list = true - --- Share system clipboard vim.opt.clipboard = 'unnamedplus' - --- Set completeopt to have a better completion experience vim.o.completeopt = 'menuone,noselect' - --- Remap for dealing with word wrap vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) - --- set termguicolors to enable highlight groups vim.opt.termguicolors = true --- Highlight on yank local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) vim.api.nvim_create_autocmd('TextYankPost', { callback = function() @@ -1419,7 +908,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { pattern = '*', }) --- Relative line numbers local numtogGrp = vim.api.nvim_create_augroup('NumberToggle', { clear = true }) vim.api.nvim_create_autocmd({ 'BufEnter', 'InsertLeave', 'FocusGained' }, { pattern = '*', @@ -1427,7 +915,6 @@ vim.api.nvim_create_autocmd({ 'BufEnter', 'InsertLeave', 'FocusGained' }, { vim.opt.relativenumber = true end, group = numtogGrp, - desc = 'Turn on relative line numbering when the buffer is entered.', }) vim.api.nvim_create_autocmd({ 'BufLeave', 'InsertEnter', 'FocusLost' }, { pattern = '*', @@ -1435,125 +922,78 @@ vim.api.nvim_create_autocmd({ 'BufLeave', 'InsertEnter', 'FocusLost' }, { vim.opt.relativenumber = false end, group = numtogGrp, - desc = 'Turn off relative line numbering when the buffer is exited.', }) ---[[ INFO: Keymaps configurations --- Make sure to change these keymaps so that they make the most sense to you ---]] - --- Improve motions +-- ========================= +-- Keymaps (treesitter keymaps removed) +-- ========================= vim.keymap.set('n', '', 'zz') vim.keymap.set('n', '', 'zz') vim.keymap.set('n', 'n', 'nzzzv') vim.keymap.set('n', 'N', 'Nzzzv') -vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move selected lines down' }) -vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move selected lines down' }) +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '<-2gv=gv") --- Improve splits navigation vim.keymap.set('n', '', 'h') vim.keymap.set('n', '', 'j') vim.keymap.set('n', '', 'k') vim.keymap.set('n', '', 'l') --- Improve pasting -vim.keymap.set('x', 'p', [["_dP]], { desc = 'Preserve previous word when pasting' }) - -vim.keymap.set('n', 'ya', ':%y+', { desc = 'Yank all content in file' }) +vim.keymap.set('x', 'p', [["_dP]]) +vim.keymap.set('n', 'ya', ':%y+') --- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open diagnostic in floating window' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Send diagnostic to loclist' }) -vim.keymap.set('n', 'dd', vim.diagnostic.disable, { desc = '[D]iagnostics [D]disable' }) -vim.keymap.set('n', 'de', vim.diagnostic.enable, { desc = '[D]iagnostics [E]nable' }) - --- Change workingdir -vim.keymap.set('n', 'cw', ':cd %:p:h:pwd', { desc = 'Change current workding dir' }) --- Fix forward jump after setting --- https://github.com/neovim/neovim/issues/20126 -vim.keymap.set('n', '', '', { noremap = true }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist) +vim.keymap.set('n', 'dd', vim.diagnostic.disable) +vim.keymap.set('n', 'de', vim.diagnostic.enable) --- Editor experience -vim.keymap.set('n', '', ':write', { desc = 'Save file' }) -vim.keymap.set('n', 'cd', ':ToggleAutoComplete', { desc = '[C]ompletion [D]isable' }) -vim.keymap.set('n', 'ce', ':ToggleAutoComplete', { desc = '[C]ompletion [E]nable' }) +vim.keymap.set('n', 'cw', ':cd %:p:h:pwd') +vim.keymap.set('n', '', '', { noremap = true }) +vim.keymap.set('n', '', ':write') +vim.keymap.set('n', 'cd', ':ToggleAutoComplete') +vim.keymap.set('n', 'ce', ':ToggleAutoComplete') --- ==================================================== --- Telescope --- ==================================================== -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +-- Telescope keymaps +vim.keymap.set('n', '?', require('telescope.builtin').oldfiles) +vim.keymap.set('n', '', require('telescope.builtin').buffers) vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { previewer = false, sorting_strategy = 'ascending', }) -end, { desc = '[/] Fuzzily search in current buffer]' }) - -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sp', require('telescope.builtin').spell_suggest, { desc = '[S][P]ell suggestion' }) -vim.keymap.set('n', 'sk', require('telescope.builtin').keymaps, { desc = '[S]earch [K]eymaps' }) -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sc', require('telescope.builtin').git_commits, { desc = '[S]earch git [C]ommits' }) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = 'Telescope [S]earch [R]esume' }) --- Also possible to pass additional configuration options. --- See `:help telescope.builtin.live_grep()` for information about particular keys +end) + +vim.keymap.set('n', 'sf', require('telescope.builtin').find_files) +vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags) +vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string) +vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep) +vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics) +vim.keymap.set('n', 'sp', require('telescope.builtin').spell_suggest) +vim.keymap.set('n', 'sk', require('telescope.builtin').keymaps) +vim.keymap.set('n', 'gf', require('telescope.builtin').git_files) +vim.keymap.set('n', 'sc', require('telescope.builtin').git_commits) +vim.keymap.set('n', 'sr', require('telescope.builtin').resume) vim.keymap.set('n', 's/', function() require('telescope.builtin').live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files', } -end, { desc = '[S]earch [/] in Open Files' }) --- Shortcut for searching your neovim configuration files +end) vim.keymap.set('n', 'sn', function() require('telescope.builtin').find_files { cwd = vim.fn.stdpath 'config' } -end, { desc = '[S]earch [N]eovim files' }) - --- ==================================================== --- Nvim Tree --- ==================================================== -vim.keymap.set('n', 'ff', ':NvimTreeFindFile', { desc = 'NvimTree [F]ind [F]ile' }) -vim.keymap.set('n', 'tt', ':NvimTreeToggle', { desc = 'NvimTree [T]ree [T]oggle' }) - --- ==================================================== --- Execute over files --- ==================================================== -vim.keymap.set('n', 'ru', ':w:!%:p', { desc = '[R][U]n current file' }) -vim.keymap.set('n', 'me', ':!chmod +x %:p', { desc = '[M]ake current file [E]xecutable' }) - --- ==================================================== --- Spectre --- ==================================================== -vim.keymap.set('n', 'P', require('spectre').open, { desc = 'Open Search and Replace' }) - --- ==================================================== --- Trouble --- ==================================================== -vim.keymap.set('n', 'xx', 'TroubleToggle', { silent = true, noremap = true, desc = 'Toggle trouble window' }) -vim.keymap.set( - 'n', - 'xw', - 'TroubleToggle workspace_diagnostics', - { silent = true, noremap = true, desc = 'Trouble diagnostics for the whole workspace' } -) -vim.keymap.set( - 'n', - 'xd', - 'TroubleToggle document_diagnostics', - { silent = true, noremap = true, desc = 'Trouble diagnostics for current document' } -) - - --- ==================================================== --- Debugging -> dap --- ==================================================== +end) + +vim.keymap.set('n', 'ru', ':w:!%:p') +vim.keymap.set('n', 'me', ':!chmod +x %:p') +vim.keymap.set('n', 'P', require('spectre').open) + +vim.keymap.set('n', 'xx', 'TroubleToggle', { silent = true, noremap = true }) +vim.keymap.set('n', 'xw', 'TroubleToggle workspace_diagnostics', { silent = true, noremap = true }) +vim.keymap.set('n', 'xd', 'TroubleToggle document_diagnostics', { silent = true, noremap = true }) + +-- DAP keymaps vim.keymap.set('n', '', ":lua require('dapui').toggle()") vim.keymap.set('n', 'dc', ":lua require('dap').continue()") vim.keymap.set('n', 'do', ":lua require('dap').step_over()") @@ -1566,19 +1006,16 @@ vim.keymap.set('n', 'd?', function() widgets.centered_float(widgets.scopes) end) vim.keymap.set('n', 'du', ":lua require('dap').step_out()") -vim.keymap.set('n', 'dl', ":lua require('dapui').float_element()", { silent = true, noremap = true, desc = 'Open floating window in Dap UI' }) -vim.keymap.set('n', 'dt', ":lua require('dap').toggle_breakpoint()", { silent = true, noremap = true, desc = 'Toggle breakpoint' }) -vim.keymap.set('n', 'dm', ":lua require('dap-python').test_method()", { silent = true, noremap = true, desc = 'DapPytest : Debug method' }) -vim.keymap.set('n', 'df', ":lua require('dap-python').test_class()", { silent = true, noremap = true, desc = 'DapPytest : Debug class' }) - --- ==================================================== --- barbar --> Tabs management --- ==================================================== -vim.keymap.set('n', '', 'BufferPrevious', { silent = true, noremap = true, desc = 'Go to previous tab' }) -vim.keymap.set('n', '', 'BufferNext', { silent = true, noremap = true, desc = 'Go to next tab' }) -vim.keymap.set('n', '', 'BufferClose', { silent = true, noremap = true, desc = 'Close current buffer' }) +vim.keymap.set('n', 'dl', ":lua require('dapui').float_element()", { silent = true, noremap = true }) +vim.keymap.set('n', 'dt', ":lua require('dap').toggle_breakpoint()", { silent = true, noremap = true }) +vim.keymap.set('n', 'dm', ":lua require('dap-python').test_method()", { silent = true, noremap = true }) +vim.keymap.set('n', 'df', ":lua require('dap-python').test_class()", { silent = true, noremap = true }) + +-- barbar +vim.keymap.set('n', '', 'BufferPrevious', { silent = true, noremap = true }) +vim.keymap.set('n', '', 'BufferNext', { silent = true, noremap = true }) +vim.keymap.set('n', '', 'BufferClose', { silent = true, noremap = true }) local opts = { noremap = true, silent = true } --- Goto buffer in position... vim.keymap.set('n', '', 'BufferGoto 1', opts) vim.keymap.set('n', '', 'BufferGoto 2', opts) vim.keymap.set('n', '', 'BufferGoto 3', opts) @@ -1590,41 +1027,30 @@ vim.keymap.set('n', '', 'BufferGoto 8', opts) vim.keymap.set('n', '', 'BufferGoto 9', opts) vim.keymap.set('n', '', 'BufferLast', opts) --- ==================================================== --- Quickfix --- ==================================================== -vim.keymap.set('n', 'cn', ':cnext', { desc = 'Next quickfix list' }) -vim.keymap.set('n', 'cp', ':cprevious', { desc = 'Previous quickfix list' }) - --- ==================================================== --- Markdown --- ==================================================== -vim.keymap.set('n', 'mp', ':MarkdownPreview', { desc = '[M]arkdown [P]review' }) +-- quickfix +vim.keymap.set('n', 'cn', ':cnext') +vim.keymap.set('n', 'cp', ':cprevious') --- ==================================================== --- git_coauthors --- ==================================================== -vim.keymap.set('n', 'ga', ':Telescope coauthors', { desc = '[G]it co-[A]uthors' }) +-- markdown +vim.keymap.set('n', 'mp', ':MarkdownPreview') --- NOTE: Custon User Commads +-- git coauthors +vim.keymap.set('n', 'ga', ':Telescope coauthors') - --- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et +-- Comment.nvim keymaps vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) vim.api.nvim_set_keymap('v', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) vim.api.nvim_set_keymap('i', '', '', { noremap = true }) --- map floaterm +-- Floaterm vim.api.nvim_set_keymap('n', '', ':FloatermToggle', { noremap = true }) vim.api.nvim_set_keymap('i', '', ':FloatermToggle', { noremap = true }) vim.api.nvim_set_keymap('t', '', ':FloatermToggle', { noremap = true, silent = true }) --- --- Define the toggle function + +-- Neo-tree toggle local function toggle_neotree() local manager = require 'neo-tree.sources.manager' local renderer = require 'neo-tree.ui.renderer' - local state = manager.get_state 'filesystem' local window_exists = renderer.window_exists(state) if window_exists then @@ -1633,34 +1059,23 @@ local function toggle_neotree() vim.cmd 'Neotree show' end end - --- Ensure the function is accessible _G.toggle_neotree = toggle_neotree - --- Map the toggle function to a key command vim.api.nvim_set_keymap('n', '', ':lua toggle_neotree()', { noremap = true, silent = true }) --- vim.api.nvim_set_keymap('n', '', ':lua toggle_neotree()', { noremap = true, silent = true }) --- vim.api.nvim_set_keymap('i', '', ':lua toggle_neotree()', { noremap = true, silent = true }) - vim.api.nvim_set_keymap('i', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) vim.api.nvim_create_augroup('EnsureTextWindowFocus', { clear = true }) - vim.api.nvim_create_autocmd('VimEnter', { group = 'EnsureTextWindowFocus', callback = function() vim.defer_fn(function() vim.cmd 'wincmd p' - end, 100) -- Adjust the delay if necessary + end, 100) end, }) --- tabstop 2 vim.api.nvim_create_augroup('CppIndent', { clear = true }) - --- Set tab width to 2 spaces for C++ files vim.api.nvim_create_autocmd('FileType', { pattern = { 'cpp', 'c', 'cc', 'h', 'hpp' }, group = 'CppIndent', @@ -1671,28 +1086,20 @@ vim.api.nvim_create_autocmd('FileType', { end, }) --- Remap copy line vim.api.nvim_set_keymap('n', 'Y', 'yy', { noremap = true, silent = true }) --- Open Neo-tree automatically on startup --- vim.cmd 'Neotree show' vim.api.nvim_set_keymap('i', '{', '{}', { noremap = true, silent = true }) - vim.keymap.set('n', '', 'wqa') --- Quick splits -vim.keymap.set('n', 'sv', 'vsplit', { desc = 'Vertical split' }) -vim.keymap.set('n', 'sh', 'split', { desc = 'Horizontal split' }) +vim.keymap.set('n', 'sv', 'vsplit') +vim.keymap.set('n', 'sh', 'split') -local ai_enabled = true - --- AI toggle +-- AI wrapper local ai_enabled = true vim.keymap.set('n', 'at', function() ai_enabled = not ai_enabled print(ai_enabled and 'AI enabled' or 'AI disabled') -end, { desc = 'Toggle AI' }) +end) --- Safe wrapper local function ai_safe(cmd) return function() if not ai_enabled then @@ -1703,31 +1110,17 @@ local function ai_safe(cmd) end end --- Keymaps using safe wrapper -vim.keymap.set('n', 'ai', ai_safe 'ChatGPT', { desc = 'Open ChatGPT UI' }) -vim.keymap.set('v', 'ac', ai_safe 'ChatGPTEditWithInstruction', { desc = 'AI edit code' }) -vim.keymap.set('v', 'ae', ai_safe 'ChatGPTExplain', { desc = 'Explain code' }) - --- creates a new tab -vim.keymap.set('n', 'tn', ':tabnew', { desc = 'New tab' }) --- closes a tab -vim.keymap.set('n', 'tc', ':tabclose', { desc = 'Close tab' }) +vim.keymap.set('n', 'ai', ai_safe 'ChatGPT') +vim.keymap.set('v', 'ac', ai_safe 'ChatGPTEditWithInstruction') +vim.keymap.set('v', 'ae', ai_safe 'ChatGPTExplain') --- kills floaterms -vim.keymap.set('n', 'fk', ':FloatermKill!', { desc = 'Kill all floaterms' }) +vim.keymap.set('n', 'tn', ':tabnew') +vim.keymap.set('n', 'tc', ':tabclose') +vim.keymap.set('n', 'fk', ':FloatermKill!') vim.keymap.set('x', 'S', '(nvim-surround-visual)', { remap = true }) - --- delete by word with ctrl backspace vim.keymap.set('i', '', '', { noremap = true }) vim.keymap.set('c', '', '', { noremap = true }) --- switch buffers quicker with shift+tab vim.keymap.set('n', '', 'BufferLineCycleNext') vim.keymap.set('n', '', 'BufferLineCyclePrev') - -vim.keymap.set("n", "is", ":TSNodeIncremental", { silent = true }) -vim.keymap.set("x", "is", ":TSNodeIncremental", { silent = true }) -vim.keymap.set("x", "ic", ":TSScopeIncremental", { silent = true }) -vim.keymap.set("x", "id", ":TSNodeDecremental", { silent = true }) - From 11581a9a582809a9a0c15728200f1a873922a1af Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Thu, 1 Jan 2026 01:47:52 -1000 Subject: [PATCH 17/22] cursor smear and cleaned up lots of settings --- init.lua | 657 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 493 insertions(+), 164 deletions(-) diff --git a/init.lua b/init.lua index 2116ebccbf5..7f44a6d9f49 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' +-- for chatgpt +_G.chatgpt_model = 'gpt-5.1-codex-mini' -- ========================= -- Lazy.nvim bootstrap @@ -21,7 +23,6 @@ vim.opt.rtp:prepend(lazypath) -- PLUGINS -- ========================= require('lazy').setup({ - -- Git 'voldikss/vim-floaterm', 'tpope/vim-fugitive', @@ -32,6 +33,28 @@ require('lazy').setup({ { 'numToStr/Comment.nvim', opts = {} }, + { + 'nvim-treesitter/nvim-treesitter', + lazy = false, + build = ':TSUpdate', + }, + + { + 'MeanderingProgrammer/treesitter-modules.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + opts = { + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', -- Alt+Space + node_incremental = '', -- Alt+Space (expand) + node_decremental = '', -- Alt+Backspace (shrink) + scope_incremental = '', -- Alt+Shift+Space (scope expand) + }, + }, + }, + }, + 'rhysd/git-messenger.vim', { 'jackMort/ChatGPT.nvim', @@ -43,7 +66,29 @@ require('lazy').setup({ }, config = function() require('chatgpt').setup { - api_key_cmd = 'echo $OPENAI_API_KEY', + openai_params = { + -- NOTE: model can be a function returning the model name + -- this is useful if you want to change the model on the fly + -- using commands + -- Example: + -- model = function() + -- if some_condition() then + -- return "gpt-5" + -- else + -- return "gpt-5-mini" + -- end + -- end, + model = function() + return _G.chatgpt_model + end, + frequency_penalty = 0, + presence_penalty = 0, + max_tokens = 4095, + temperature = 0.2, + top_p = 0.1, + n = 1, + api_key_cmd = 'echo $OPENAI_API_KEY', + }, } end, }, @@ -112,15 +157,28 @@ require('lazy').setup({ { 'sphamba/smear-cursor.nvim', - opts = { -- Default Range - stiffness = 0.6, -- 0.6 [0, 1] - trailing_stiffness = 0.4, -- 0.45 [0, 1] - stiffness_insert_mode = 0.7, -- 0.5 [0, 1] - trailing_stiffness_insert_mode = 0.7, -- 0.5 [0, 1] - damping = 0.8, -- 0.85 [0, 1] - damping_insert_mode = 0.8, -- 0.9 [0, 1] - distance_stop_animating = 0.1, -- 0.1 > 0 - }, + opts = { + time_interval = 3, + cursor_color = '#ff4000', + particles_enabled = true, + stiffness = 0.5, + trailing_stiffness = 0.2, + trailing_exponent = 5, + damping = 0.6, + gradient_exponent = 0, + gamma = 1, + never_draw_over_target = true, + hide_target_hack = true, + particle_spread = 1, + particles_per_second = 500, + particles_per_length = 50, + particle_max_lifetime = 800, + particle_max_initial_velocity = 20, + particle_velocity_from_cursor = 0.5, + particle_damping = 0.15, + particle_gravity = -50, + min_distance_emit_particles = 0, + }, }, { @@ -417,7 +475,7 @@ require('lazy').setup({ -- Telescope { 'nvim-telescope/telescope.nvim', - branch = '0.1.x', + branch = 'master', dependencies = { 'nvim-lua/plenary.nvim', { @@ -868,6 +926,247 @@ require('lazy').setup({ }, }, {}) +-- ========================================= +-- ============ START SMEAR PROFILE ======== +-- ========================================= +local smear = require 'smear_cursor' + +local smear_profiles = { + silver_blade = { + -- General + cursor_color = "#ffe6b2", + smear_between_buffers = true, + smear_between_neighbor_lines = true, + min_horizontal_distance_smear = 0, + min_vertical_distance_smear = 0, + smear_horizontally = true, + smear_vertically = true, + smear_diagonally = true, + smear_to_cmd = true, + scroll_buffer_space = true, + + legacy_computing_symbols_support = false, + legacy_computing_symbols_support_vertical_bars = false, + use_diagonal_blocks = true, + + vertical_bar_cursor = false, + smear_insert_mode = true, + vertical_bar_cursor_insert_mode = true, + smear_replace_mode = false, + smear_terminal_mode = false, + horizontal_bar_cursor_replace_mode = true, + + never_draw_over_target = false, + hide_target_hack = false, + + max_kept_windows = 50, + windows_zindex = 300, + filetypes_disabled = {}, + + -- High FPS (smooth) + time_interval = 7, + delay_disable = nil, + delay_event_to_smear = 1, + delay_after_key = 6, + + -- Physics: fast head, laggy tail, smooth decay + stiffness = 0.95, + trailing_stiffness = 0.33, + anticipation = 0.06, + damping = 0.90, + trailing_exponent = 5.5, + distance_stop_animating = 0.06, + + -- Insert mode: match feel + stiffness_insert_mode = 0.95, + trailing_stiffness_insert_mode = 0.7, + damping_insert_mode = 0.92, + trailing_exponent_insert_mode = 5.5, + distance_stop_animating_vertical_bar = 0.25, + + -- Diagonal + shading tuned for “pretty” + max_slope_horizontal = (1 / 3) / 1.7, + min_slope_vertical = 2 * 1.7, + max_angle_difference_diagonal = math.pi / 18, + max_offset_diagonal = 0.18, + min_shade_no_diagonal = 0.22, + min_shade_no_diagonal_vertical_bar = 0.55, + + -- Rich blending (costly but nice) + color_levels = 24, + gamma = 2.2, + gradient_exponent = 2.8, + max_shade_no_matrix = 0.78, + matrix_pixel_threshold = 0.72, + matrix_pixel_threshold_vertical_bar = 0.28, + matrix_pixel_min_factor = 0.55, + volume_reduction_exponent = 0.22, + minimum_volume_factor = 0.78, + + -- Longer trail + max_length = 34, + max_length_insert_mode = 2, + + -- Particles off + particles_enabled = false, + particle_max_num = 100, + particle_spread = 0.5, + particles_per_second = 200, + particles_per_length = 1.0, + particle_max_lifetime = 300, + particle_lifetime_distribution_exponent = 5, + particle_max_initial_velocity = 10, + particle_velocity_from_cursor = 0.2, + particle_random_velocity = 100, + particle_damping = 0.2, + particle_gravity = 20, + min_distance_emit_particles = 1.5, + particle_switch_octant_braille = 0.3, + particles_over_text = false, + }, + -- 1) Frost Mist + eco_smear = { + -- General (keep core behavior) + smear_between_buffers = true, + smear_between_neighbor_lines = true, + min_horizontal_distance_smear = 1, -- reduces tiny smears + min_vertical_distance_smear = 1, + smear_horizontally = true, + smear_vertically = true, + smear_diagonally = false, -- big CPU win + smear_to_cmd = true, + scroll_buffer_space = false, -- cheaper on scroll + + legacy_computing_symbols_support = false, + legacy_computing_symbols_support_vertical_bars = false, + use_diagonal_blocks = true, + + vertical_bar_cursor = false, + smear_insert_mode = true, + vertical_bar_cursor_insert_mode = true, + smear_replace_mode = false, + smear_terminal_mode = false, + horizontal_bar_cursor_replace_mode = true, + + never_draw_over_target = false, + hide_target_hack = false, + + max_kept_windows = 20, -- fewer render windows kept + windows_zindex = 300, + filetypes_disabled = {}, + + -- Lower FPS (much cheaper) + time_interval = 14, + delay_disable = nil, + delay_event_to_smear = 2, + delay_after_key = 10, + + -- Physics: still fast head, shorter/cheaper tail + stiffness = 0.90, + trailing_stiffness = 0.28, + anticipation = 0.04, + damping = 0.88, + trailing_exponent = 3.0, + distance_stop_animating = 0.12, + + -- Insert mode: keep it tight + stiffness_insert_mode = 0.90, + trailing_stiffness_insert_mode = 0.28, + damping_insert_mode = 0.90, + trailing_exponent_insert_mode = 3.0, + distance_stop_animating_vertical_bar = 0.30, + + -- Simpler shading (cheaper) + max_slope_horizontal = (1 / 3) / 1.6, + min_slope_vertical = 2 * 1.6, + max_angle_difference_diagonal = math.pi / 16, + max_offset_diagonal = 0.2, + min_shade_no_diagonal = 0.30, + min_shade_no_diagonal_vertical_bar = 0.60, + + -- Reduced blending cost + color_levels = 16, + gamma = 2.2, + gradient_exponent = 1.3, + max_shade_no_matrix = 0.80, + matrix_pixel_threshold = 0.80, + matrix_pixel_threshold_vertical_bar = 0.35, + matrix_pixel_min_factor = 0.65, + volume_reduction_exponent = 0.35, + minimum_volume_factor = 0.82, + + -- Shorter trail + max_length = 18, + max_length_insert_mode = 1, + + -- Particles off + particles_enabled = false, + particle_max_num = 100, + particle_spread = 0.5, + particles_per_second = 200, + particles_per_length = 1.0, + particle_max_lifetime = 300, + particle_lifetime_distribution_exponent = 5, + particle_max_initial_velocity = 10, + particle_velocity_from_cursor = 0.2, + particle_random_velocity = 100, + particle_damping = 0.2, + particle_gravity = 20, + min_distance_emit_particles = 1.5, + particle_switch_octant_braille = 0.3, + particles_over_text = false, + }, + +} + +local smear_profile_order = { + 'silver_blade', + 'eco_smear', +} + +local current_idx = 1 + +local function apply_smear_profile(name) + local p = smear_profiles[name] + if not p then + vim.notify('Unknown smear profile: ' .. tostring(name), vim.log.levels.ERROR) + return + end + smear.setup(vim.deepcopy(p)) + vim.g.smear_cursor_profile = name + vim.notify('smear-cursor → ' .. name) +end + +-- Commands +vim.api.nvim_create_user_command('SmearProfile', function(opts) + apply_smear_profile(opts.args) +end, { + nargs = 1, + complete = function() + return smear_profile_order + end, +}) + +vim.api.nvim_create_user_command('SmearProfileNext', function() + current_idx = (current_idx % #smear_profile_order) + 1 + apply_smear_profile(smear_profile_order[current_idx]) +end, {}) + +vim.api.nvim_create_user_command('SmearProfilePrev', function() + current_idx = ((current_idx - 2) % #smear_profile_order) + 1 + apply_smear_profile(smear_profile_order[current_idx]) +end, {}) + +-- Keybindings (edit if you want) +vim.keymap.set('n', 'pn', 'SmearProfileNext', { desc = 'Smear profile: next' }) +vim.keymap.set('n', 'pp', 'SmearProfilePrev', { desc = 'Smear profile: prev' }) + +-- Apply a default on startup (pick one) +apply_smear_profile 'silver_blade' +-- ========================================= +-- ============ END SMEAR PROFILE ========== +-- ========================================= + -- ========================= -- Editor settings -- ========================= @@ -899,6 +1198,40 @@ vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = tr vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) vim.opt.termguicolors = true +-- ============================ +-- ====== TABSTOP START ======= +-- ============================ +local function set_indent(ts) + vim.opt_local.expandtab = true + vim.opt_local.tabstop = ts + vim.opt_local.shiftwidth = ts + vim.opt_local.softtabstop = ts +end + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "lua", "javascript", "typescript", "tsx", "json", "yaml", "toml", "html", "css", "rust", "c", "cpp" }, + callback = function() set_indent(2) end, +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "python", "sh", "bash", "zsh", "go" }, + callback = function() set_indent(4) end, +}) + +-- Makefiles must use real tabs +vim.api.nvim_create_autocmd("FileType", { + pattern = { "make" }, + callback = function() + vim.opt_local.expandtab = false + vim.opt_local.tabstop = 8 + vim.opt_local.shiftwidth = 8 + vim.opt_local.softtabstop = 0 + end, +}) +-- ============================ +-- ====== TABSTOP END ========= +-- ============================ + local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) vim.api.nvim_create_autocmd('TextYankPost', { callback = function() @@ -927,127 +1260,170 @@ vim.api.nvim_create_autocmd({ 'BufLeave', 'InsertEnter', 'FocusLost' }, { -- ========================= -- Keymaps (treesitter keymaps removed) -- ========================= -vim.keymap.set('n', '', 'zz') -vim.keymap.set('n', '', 'zz') -vim.keymap.set('n', 'n', 'nzzzv') -vim.keymap.set('n', 'N', 'Nzzzv') -vim.keymap.set('v', 'J', ":m '>+1gv=gv") -vim.keymap.set('v', 'K', ":m '<-2gv=gv") - -vim.keymap.set('n', '', 'h') -vim.keymap.set('n', '', 'j') -vim.keymap.set('n', '', 'k') -vim.keymap.set('n', '', 'l') - -vim.keymap.set('x', 'p', [["_dP]]) -vim.keymap.set('n', 'ya', ':%y+') - -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next) -vim.keymap.set('n', 'e', vim.diagnostic.open_float) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -vim.keymap.set('n', 'dd', vim.diagnostic.disable) -vim.keymap.set('n', 'de', vim.diagnostic.enable) - -vim.keymap.set('n', 'cw', ':cd %:p:h:pwd') -vim.keymap.set('n', '', '', { noremap = true }) -vim.keymap.set('n', '', ':write') -vim.keymap.set('n', 'cd', ':ToggleAutoComplete') -vim.keymap.set('n', 'ce', ':ToggleAutoComplete') - --- Telescope keymaps -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles) -vim.keymap.set('n', '', require('telescope.builtin').buffers) + +-- scrolling / search centering +vim.keymap.set('n', '', 'zz', { desc = 'Scroll down and center cursor' }) +vim.keymap.set('n', '', 'zz', { desc = 'Scroll up and center cursor' }) +vim.keymap.set('n', 'n', 'nzzzv', { desc = 'Next search result and center' }) +vim.keymap.set('n', 'N', 'Nzzzv', { desc = 'Previous search result and center' }) + +-- move selected lines +vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move selection down' }) +vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move selection up' }) + +-- window navigation +vim.keymap.set('n', '', 'h', { desc = 'Go to left window' }) +vim.keymap.set('n', '', 'j', { desc = 'Go to lower window' }) +vim.keymap.set('n', '', 'k', { desc = 'Go to upper window' }) +vim.keymap.set('n', '', 'l', { desc = 'Go to right window' }) + +-- clipboard / yank +vim.keymap.set('x', 'p', [["_dP]], { desc = 'Paste without overwriting register' }) +vim.keymap.set('n', 'ya', ':%y+', { desc = 'Yank entire buffer to clipboard' }) + +-- diagnostics +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Previous diagnostic' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Next diagnostic' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic under cursor' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Diagnostics to loclist' }) +vim.keymap.set('n', 'dd', vim.diagnostic.disable, { desc = 'Disable diagnostics' }) +vim.keymap.set('n', 'de', vim.diagnostic.enable, { desc = 'Enable diagnostics' }) + +-- misc +vim.keymap.set('n', 'cw', ':cd %:p:h:pwd', { desc = 'cd to current file directory' }) +vim.keymap.set('n', '', '', { noremap = true, desc = 'Jump forward in jumplist' }) +vim.keymap.set('n', '', ':write', { desc = 'Save file' }) +vim.keymap.set('n', 'cd', ':ToggleAutoComplete', { desc = 'Toggle autocomplete' }) +vim.keymap.set('n', 'ce', ':ToggleAutoComplete', { desc = 'Toggle autocomplete (alias)' }) + +-- Telescope +vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = 'Find recently opened files' }) +vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = 'List open buffers' }) vim.keymap.set('n', '/', function() require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { previewer = false, sorting_strategy = 'ascending', }) -end) - -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics) -vim.keymap.set('n', 'sp', require('telescope.builtin').spell_suggest) -vim.keymap.set('n', 'sk', require('telescope.builtin').keymaps) -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files) -vim.keymap.set('n', 'sc', require('telescope.builtin').git_commits) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume) +end, { desc = 'Fuzzy search in current buffer' }) + +vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = 'Find files' }) +vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = 'Search help tags' }) +vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = 'Search word under cursor' }) +vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = 'Live grep' }) +vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = 'Search diagnostics' }) +vim.keymap.set('n', 'sp', require('telescope.builtin').spell_suggest, { desc = 'Spell suggestions' }) +vim.keymap.set('n', 'sk', require('telescope.builtin').keymaps, { desc = 'Search keymaps' }) +vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Find git files' }) +vim.keymap.set('n', 'sc', require('telescope.builtin').git_commits, { desc = 'Search git commits' }) +vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = 'Resume last Telescope picker' }) + vim.keymap.set('n', 's/', function() require('telescope.builtin').live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files', } -end) +end, { desc = 'Live grep in open files' }) + vim.keymap.set('n', 'sn', function() require('telescope.builtin').find_files { cwd = vim.fn.stdpath 'config' } -end) - -vim.keymap.set('n', 'ru', ':w:!%:p') -vim.keymap.set('n', 'me', ':!chmod +x %:p') -vim.keymap.set('n', 'P', require('spectre').open) - -vim.keymap.set('n', 'xx', 'TroubleToggle', { silent = true, noremap = true }) -vim.keymap.set('n', 'xw', 'TroubleToggle workspace_diagnostics', { silent = true, noremap = true }) -vim.keymap.set('n', 'xd', 'TroubleToggle document_diagnostics', { silent = true, noremap = true }) - --- DAP keymaps -vim.keymap.set('n', '', ":lua require('dapui').toggle()") -vim.keymap.set('n', 'dc', ":lua require('dap').continue()") -vim.keymap.set('n', 'do', ":lua require('dap').step_over()") -vim.keymap.set('n', 'di', ":lua require('dap').step_into()") +end, { desc = 'Search Neovim config files' }) + +-- run / permissions +vim.keymap.set('n', 'ru', ':w:!%:p', { desc = 'Save and run current file' }) +vim.keymap.set('n', 'me', ':!chmod +x %:p', { desc = 'Make file executable' }) +vim.keymap.set('n', 'P', require('spectre').open, { desc = 'Open Spectre search/replace' }) + +-- Trouble +vim.keymap.set('n', 'xx', 'TroubleToggle', { silent = true, noremap = true, desc = 'Toggle Trouble' }) +vim.keymap.set('n', 'xw', 'TroubleToggle workspace_diagnostics', { silent = true, noremap = true, desc = 'Workspace diagnostics (Trouble)' }) +vim.keymap.set('n', 'xd', 'TroubleToggle document_diagnostics', { silent = true, noremap = true, desc = 'Document diagnostics (Trouble)' }) + +-- DAP +vim.keymap.set('n', '', ":lua require('dapui').toggle()", { desc = 'Toggle DAP UI' }) +vim.keymap.set('n', 'dc', ":lua require('dap').continue()", { desc = 'DAP continue' }) +vim.keymap.set('n', 'do', ":lua require('dap').step_over()", { desc = 'DAP step over' }) +vim.keymap.set('n', 'di', ":lua require('dap').step_into()", { desc = 'DAP step into' }) vim.keymap.set('n', 'dk', function() require('dap.ui.widgets').hover() -end) +end, { desc = 'DAP hover value' }) vim.keymap.set('n', 'd?', function() local widgets = require 'dap.ui.widgets' widgets.centered_float(widgets.scopes) -end) -vim.keymap.set('n', 'du', ":lua require('dap').step_out()") -vim.keymap.set('n', 'dl', ":lua require('dapui').float_element()", { silent = true, noremap = true }) -vim.keymap.set('n', 'dt', ":lua require('dap').toggle_breakpoint()", { silent = true, noremap = true }) -vim.keymap.set('n', 'dm', ":lua require('dap-python').test_method()", { silent = true, noremap = true }) -vim.keymap.set('n', 'df', ":lua require('dap-python').test_class()", { silent = true, noremap = true }) +end, { desc = 'DAP scopes' }) +vim.keymap.set('n', 'du', ":lua require('dap').step_out()", { desc = 'DAP step out' }) +vim.keymap.set('n', 'dl', ":lua require('dapui').float_element()", { silent = true, noremap = true, desc = 'DAP floating window' }) +vim.keymap.set('n', 'dt', ":lua require('dap').toggle_breakpoint()", { silent = true, noremap = true, desc = 'Toggle breakpoint' }) +vim.keymap.set('n', 'dm', ":lua require('dap-python').test_method()", { silent = true, noremap = true, desc = 'DAP test method' }) +vim.keymap.set('n', 'df', ":lua require('dap-python').test_class()", { silent = true, noremap = true, desc = 'DAP test class' }) -- barbar -vim.keymap.set('n', '', 'BufferPrevious', { silent = true, noremap = true }) -vim.keymap.set('n', '', 'BufferNext', { silent = true, noremap = true }) -vim.keymap.set('n', '', 'BufferClose', { silent = true, noremap = true }) +vim.keymap.set('n', '', 'BufferPrevious', { silent = true, noremap = true, desc = 'Previous buffer' }) +vim.keymap.set('n', '', 'BufferNext', { silent = true, noremap = true, desc = 'Next buffer' }) +vim.keymap.set('n', '', 'BufferClose', { silent = true, noremap = true, desc = 'Close buffer' }) + local opts = { noremap = true, silent = true } -vim.keymap.set('n', '', 'BufferGoto 1', opts) -vim.keymap.set('n', '', 'BufferGoto 2', opts) -vim.keymap.set('n', '', 'BufferGoto 3', opts) -vim.keymap.set('n', '', 'BufferGoto 4', opts) -vim.keymap.set('n', '', 'BufferGoto 5', opts) -vim.keymap.set('n', '', 'BufferGoto 6', opts) -vim.keymap.set('n', '', 'BufferGoto 7', opts) -vim.keymap.set('n', '', 'BufferGoto 8', opts) -vim.keymap.set('n', '', 'BufferGoto 9', opts) -vim.keymap.set('n', '', 'BufferLast', opts) +vim.keymap.set('n', '', 'BufferLineGoToBuffer 1', vim.tbl_extend('force', opts, { desc = 'Go to buffer 1' })) +vim.keymap.set('n', '', 'BufferLineGoToBuffer 2', vim.tbl_extend('force', opts, { desc = 'Go to buffer 2' })) +vim.keymap.set('n', '', 'BufferLineGoToBuffer 3', vim.tbl_extend('force', opts, { desc = 'Go to buffer 3' })) +vim.keymap.set('n', '', 'BufferLineGoToBuffer 4', vim.tbl_extend('force', opts, { desc = 'Go to buffer 4' })) +vim.keymap.set('n', '', 'BufferLineGoToBuffer 5', vim.tbl_extend('force', opts, { desc = 'Go to buffer 5' })) +vim.keymap.set('n', '', 'BufferLineGoToBuffer 6', vim.tbl_extend('force', opts, { desc = 'Go to buffer 6' })) +vim.keymap.set('n', '', 'BufferLineGoToBuffer 7', vim.tbl_extend('force', opts, { desc = 'Go to buffer 7' })) +vim.keymap.set('n', '', 'BufferLineGoToBuffer 8', vim.tbl_extend('force', opts, { desc = 'Go to buffer 8' })) +vim.keymap.set('n', '', 'BufferLineGoToBuffer 9', vim.tbl_extend('force', opts, { desc = 'Go to buffer 9' })) +vim.keymap.set('n', '', 'BufferLast', vim.tbl_extend('force', opts, { desc = 'Go to last buffer' })) -- quickfix -vim.keymap.set('n', 'cn', ':cnext') -vim.keymap.set('n', 'cp', ':cprevious') +vim.keymap.set('n', 'cn', ':cnext', { desc = 'Next quickfix item' }) +vim.keymap.set('n', 'cp', ':cprevious', { desc = 'Previous quickfix item' }) -- markdown -vim.keymap.set('n', 'mp', ':MarkdownPreview') +vim.keymap.set('n', 'mp', ':MarkdownPreview', { desc = 'Markdown preview' }) --- git coauthors -vim.keymap.set('n', 'ga', ':Telescope coauthors') +-- git +vim.keymap.set('n', 'ga', ':Telescope coauthors', { desc = 'Select git co-authors' }) --- Comment.nvim keymaps -vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('v', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +-- AI model switching +vim.keymap.set('n', 'an', function() + _G.chatgpt_model = 'gpt-5-nano' + print 'ChatGPT → gpt-5-nano' +end, { desc = 'ChatGPT model: gpt-5-nano' }) --- Floaterm -vim.api.nvim_set_keymap('n', '', ':FloatermToggle', { noremap = true }) -vim.api.nvim_set_keymap('i', '', ':FloatermToggle', { noremap = true }) -vim.api.nvim_set_keymap('t', '', ':FloatermToggle', { noremap = true, silent = true }) +vim.keymap.set('n', 'ac', function() + _G.chatgpt_model = 'gpt-5.1-codex-mini' + print 'ChatGPT → gpt-5.1-codex-mini' +end, { desc = 'ChatGPT model: gpt-5.1-codex-mini' }) --- Neo-tree toggle +vim.keymap.set('n', 'ai', 'ChatGPT', { desc = 'Open ChatGPT prompt' }) + +-- delete backwards +vim.keymap.set({ 'i', 'c' }, '', '', { noremap = true, desc = 'Delete previous word' }) + +vim.keymap.set('n', '', 'BufferLineCycleNext', { desc = 'Go to next tab' }) +vim.keymap.set('n', '', 'BufferLineCyclePrev', { desc = 'Go backwards a tab' }) + +-- install treesitter parsers +require('nvim-treesitter').install { 'c', 'rust' } + +vim.keymap.set('n', 'tc', ':tabclose', { desc = 'Close current tab' }) +vim.keymap.set('n', 'fk', ':FloatermKill!', { desc = 'Kill all floaterm terminals' }) +vim.keymap.set('x', 'S', '(nvim-surround-visual)', { remap = true }, { desc = 'Surround selected text' }) + +-- yank binding +vim.api.nvim_set_keymap('n', 'Y', 'yy', { noremap = true, silent = true }) + +-- exit and save +vim.keymap.set('n', '', 'wqa') + +-- split views +vim.keymap.set('n', 'sv', 'vsplit') +vim.keymap.set('n', 'sh', 'split') + +-- signature help +vim.api.nvim_set_keymap('i', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) + +-- toggle neotree local function toggle_neotree() local manager = require 'neo-tree.sources.manager' local renderer = require 'neo-tree.ui.renderer' @@ -1062,65 +1438,18 @@ end _G.toggle_neotree = toggle_neotree vim.api.nvim_set_keymap('n', '', ':lua toggle_neotree()', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('i', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) - -vim.api.nvim_create_augroup('EnsureTextWindowFocus', { clear = true }) -vim.api.nvim_create_autocmd('VimEnter', { - group = 'EnsureTextWindowFocus', - callback = function() - vim.defer_fn(function() - vim.cmd 'wincmd p' - end, 100) - end, -}) - -vim.api.nvim_create_augroup('CppIndent', { clear = true }) -vim.api.nvim_create_autocmd('FileType', { - pattern = { 'cpp', 'c', 'cc', 'h', 'hpp' }, - group = 'CppIndent', - callback = function() - vim.opt_local.tabstop = 2 - vim.opt_local.shiftwidth = 2 - vim.opt_local.expandtab = true - end, -}) - -vim.api.nvim_set_keymap('n', 'Y', 'yy', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('i', '{', '{}', { noremap = true, silent = true }) -vim.keymap.set('n', '', 'wqa') - -vim.keymap.set('n', 'sv', 'vsplit') -vim.keymap.set('n', 'sh', 'split') - --- AI wrapper -local ai_enabled = true -vim.keymap.set('n', 'at', function() - ai_enabled = not ai_enabled - print(ai_enabled and 'AI enabled' or 'AI disabled') -end) - -local function ai_safe(cmd) - return function() - if not ai_enabled then - print 'AI is disabled' - return - end - vim.cmd(cmd) - end -end - -vim.keymap.set('n', 'ai', ai_safe 'ChatGPT') -vim.keymap.set('v', 'ac', ai_safe 'ChatGPTEditWithInstruction') -vim.keymap.set('v', 'ae', ai_safe 'ChatGPTExplain') +-- Floaterm +vim.api.nvim_set_keymap('n', '', ':FloatermToggle', { noremap = true }) +vim.api.nvim_set_keymap('i', '', ':FloatermToggle', { noremap = true }) +vim.api.nvim_set_keymap('t', '', ':FloatermToggle', { noremap = true, silent = true }) -vim.keymap.set('n', 'tn', ':tabnew') -vim.keymap.set('n', 'tc', ':tabclose') -vim.keymap.set('n', 'fk', ':FloatermKill!') +-- Comment.nvim keymaps +vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.blockwise.current()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', '', 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', '', 'lua require("Comment.api").toggle.blockwise(vim.fn.visualmode())', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) -vim.keymap.set('x', 'S', '(nvim-surround-visual)', { remap = true }) -vim.keymap.set('i', '', '', { noremap = true }) -vim.keymap.set('c', '', '', { noremap = true }) +-- git coauthors +vim.keymap.set('n', 'ga', ':Telescope coauthors') -vim.keymap.set('n', '', 'BufferLineCycleNext') -vim.keymap.set('n', '', 'BufferLineCyclePrev') From 469cb3c87462678880cbe03ff4cb94c340064744 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Thu, 1 Jan 2026 02:08:36 -1000 Subject: [PATCH 18/22] tab options --- init.lua | 51 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/init.lua b/init.lua index 7f44a6d9f49..9d5233032cf 100644 --- a/init.lua +++ b/init.lua @@ -37,6 +37,23 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', lazy = false, build = ':TSUpdate', + opts = { + ensure_installed = { + 'lua', + 'rust', + 'python', + 'javascript', + 'typescript', + 'c', + 'c_sharp', + 'cpp', + 'bash', + 'json', + 'yaml', + 'toml', + }, + highlight = { enable = true }, + }, }, { @@ -220,9 +237,15 @@ require('lazy').setup({ dependencies = 'nvim-tree/nvim-web-devicons', opts = { options = { + mode = 'buffers', -- tabs or buffers diagnostics = 'nvim_lsp', show_buffer_close_icons = false, show_close_icon = false, + hover = { + enabled = true, + delay = 200, + reveal = {'close'} + }, }, }, }, @@ -934,7 +957,7 @@ local smear = require 'smear_cursor' local smear_profiles = { silver_blade = { -- General - cursor_color = "#ffe6b2", + cursor_color = '#ffe6b2', smear_between_buffers = true, smear_between_neighbor_lines = true, min_horizontal_distance_smear = 0, @@ -1116,7 +1139,6 @@ local smear_profiles = { particle_switch_octant_braille = 0.3, particles_over_text = false, }, - } local smear_profile_order = { @@ -1208,19 +1230,23 @@ local function set_indent(ts) vim.opt_local.softtabstop = ts end -vim.api.nvim_create_autocmd("FileType", { - pattern = { "lua", "javascript", "typescript", "tsx", "json", "yaml", "toml", "html", "css", "rust", "c", "cpp" }, - callback = function() set_indent(2) end, +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'lua', 'javascript', 'typescript', 'tsx', 'json', 'yaml', 'toml', 'html', 'css', 'rust', 'c', 'cpp' }, + callback = function() + set_indent(2) + end, }) -vim.api.nvim_create_autocmd("FileType", { - pattern = { "python", "sh", "bash", "zsh", "go" }, - callback = function() set_indent(4) end, +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'python', 'sh', 'bash', 'zsh', 'go' }, + callback = function() + set_indent(4) + end, }) -- Makefiles must use real tabs -vim.api.nvim_create_autocmd("FileType", { - pattern = { "make" }, +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'make' }, callback = function() vim.opt_local.expandtab = false vim.opt_local.tabstop = 8 @@ -1402,9 +1428,6 @@ vim.keymap.set({ 'i', 'c' }, '', '', { noremap = true, desc = 'Delete vim.keymap.set('n', '', 'BufferLineCycleNext', { desc = 'Go to next tab' }) vim.keymap.set('n', '', 'BufferLineCyclePrev', { desc = 'Go backwards a tab' }) --- install treesitter parsers -require('nvim-treesitter').install { 'c', 'rust' } - vim.keymap.set('n', 'tc', ':tabclose', { desc = 'Close current tab' }) vim.keymap.set('n', 'fk', ':FloatermKill!', { desc = 'Kill all floaterm terminals' }) vim.keymap.set('x', 'S', '(nvim-surround-visual)', { remap = true }, { desc = 'Surround selected text' }) @@ -1453,3 +1476,5 @@ vim.api.nvim_set_keymap('i', '', '', { noremap = true }) -- git coauthors vim.keymap.set('n', 'ga', ':Telescope coauthors') +-- install treesitter parsers +require('nvim-treesitter').install { 'c', 'rust', 'gdscript', 'c#' } From 291ae1ea52096c793c4821de5a5d42a92f3aa64e Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Thu, 1 Jan 2026 18:36:08 -1000 Subject: [PATCH 19/22] lots of keybinds and familiar things changed --- init.lua | 379 ++++++++++++++++++++++++++++----------- lua/bootstrap/deps.lua | 33 ++++ lua/bootstrap/pacman.lua | 111 ++++++++++++ 3 files changed, 422 insertions(+), 101 deletions(-) create mode 100644 lua/bootstrap/deps.lua create mode 100644 lua/bootstrap/pacman.lua diff --git a/init.lua b/init.lua index 9d5233032cf..523c4fda866 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,8 @@ -vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' --- for chatgpt -_G.chatgpt_model = 'gpt-5.1-codex-mini' +vim.g.mapleader = ' ' + +-- install deps if need to +require("bootstrap.pacman") -- ========================= -- Lazy.nvim bootstrap @@ -73,42 +74,6 @@ require('lazy').setup({ }, 'rhysd/git-messenger.vim', - { - 'jackMort/ChatGPT.nvim', - event = 'VeryLazy', - dependencies = { - 'nvim-lua/plenary.nvim', - 'MunifTanjim/nui.nvim', - 'nvim-telescope/telescope.nvim', - }, - config = function() - require('chatgpt').setup { - openai_params = { - -- NOTE: model can be a function returning the model name - -- this is useful if you want to change the model on the fly - -- using commands - -- Example: - -- model = function() - -- if some_condition() then - -- return "gpt-5" - -- else - -- return "gpt-5-mini" - -- end - -- end, - model = function() - return _G.chatgpt_model - end, - frequency_penalty = 0, - presence_penalty = 0, - max_tokens = 4095, - temperature = 0.2, - top_p = 0.1, - n = 1, - api_key_cmd = 'echo $OPENAI_API_KEY', - }, - } - end, - }, { 'lewis6991/gitsigns.nvim', @@ -218,7 +183,24 @@ require('lazy').setup({ 'MunifTanjim/nui.nvim', }, opts = { + enable_preview = true, + filesystem = { + -- open images (and anything else) externally + commands = { + system_open = function(state) + local node = state.tree:get_node() + local path = node:get_id() -- absolute path + vim.fn.jobstart({ 'imv', path }, { detach = true }) + end, + }, + window = { + mappings = { + ['P'] = 'toggle_preview', + ['O'] = 'system_open', -- press O to open with external viewer + }, + }, + filtered_items = { visible = false, hide_dotfiles = true, @@ -230,25 +212,33 @@ require('lazy').setup({ }, }, - -- Buffers/tabs + -- LAZY PLUGIN SPEC (replace bufferline with barbar) { - 'akinsho/bufferline.nvim', - version = '*', - dependencies = 'nvim-tree/nvim-web-devicons', + 'romgrk/barbar.nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons', + 'lewis6991/gitsigns.nvim', -- optional, for git status icons + }, + init = function() + vim.g.barbar_auto_setup = false + end, opts = { - options = { - mode = 'buffers', -- tabs or buffers - diagnostics = 'nvim_lsp', - show_buffer_close_icons = false, - show_close_icon = false, - hover = { - enabled = true, - delay = 200, - reveal = {'close'} - }, + animation = true, + auto_hide = false, + tabpages = false, -- show buffers, not Vim tabpages + clickable = true, + icons = { + preset = 'slanted', + button = '󰅖', + }, + + -- Treat neo-tree as a sidebar so it doesn't become a "tab" and layout stays sane + sidebar_filetypes = { + ['neo-tree'] = { event = 'BufWipeout' }, }, }, }, + 'nvim-tree/nvim-web-devicons', { @@ -335,16 +325,6 @@ require('lazy').setup({ { 'nvim-pack/nvim-spectre', opts = {} }, - { - 'romgrk/barbar.nvim', - event = 'BufEnter', - dependencies = 'nvim-tree/nvim-web-devicons', - init = function() - vim.g.barbar_auto_setup = false - end, - lazy = true, - }, - { 'lukas-reineke/indent-blankline.nvim', main = 'ibl', @@ -605,7 +585,7 @@ require('lazy').setup({ map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') map('rn', vim.lsp.buf.rename, '[R]e[n]ame') map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - map('K', vim.lsp.buf.hover, 'Hover Documentation') + map('T', vim.lsp.buf.hover, 'Hover Documentation') map('', vim.lsp.buf.signature_help, 'Signature Documentation') local client = vim.lsp.get_client_by_id(event.data.client_id) @@ -866,6 +846,202 @@ require('lazy').setup({ end, }, + { + 'Kurama622/llm.nvim', + dependencies = { 'nvim-lua/plenary.nvim', 'MunifTanjim/nui.nvim' }, + cmd = { 'LLMSessionToggle', 'LLMSelectedTextHandler', 'LLMAppHandler' }, + config = function() + require('llm').setup { + -- GitHub Models (Azure inference) + url = 'https://api.openai.com/v1/chat/completions', + api_type = 'openai', + + -- Set this to what you want to use (must support /chat/completions) + model = _G.chatgpt_model or 'gpt-5-nano', + + -- Sensible coding defaults + --max_tokens = 4095, + --temperature = 0.2, + --top_p = 0.1, + + -- Keep it code-focused + prompt = 'You are a helpful programming assistant. Be concise, show code when needed, and prefer practical fixes.', + -- Visual selection -> context prompt + selected_text_handler = { + prompt = function(selection) + return string.format( + 'You are a helpful programming assistant.\n\n' .. 'Context (selected text):\n' .. '```text\n%s\n```\n\n' .. 'Task:\n', + selection + ) + end, + }, + + -- Optional cosmetics (minimal) + spinner = { + text = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' }, + hl = 'Title', + }, + prefix = { + user = { text = 'You: ', hl = 'Title' }, + assistant = { text = 'AI: ', hl = 'Added' }, + }, + + -- Persist chat history + save_session = true, + max_history = 30, + max_history_name_length = 40, + + -- Keymaps inside the session UI + keys = { + -- Input window + ['Input:Submit'] = { mode = 'i', key = '' }, -- Enter sends (your issue) + ['Input:Cancel'] = { mode = { 'n', 'i' }, key = '' }, + ['Input:Resend'] = { mode = { 'n', 'i' }, key = '' }, + + -- History (only if save_session=true) + ['Input:HistoryNext'] = { mode = { 'n', 'i' }, key = '' }, + ['Input:HistoryPrev'] = { mode = { 'n', 'i' }, key = '' }, + + -- Output window ("split" style) + ['Output:Ask'] = { mode = 'n', key = 'i' }, + ['Output:Cancel'] = { mode = 'n', key = '' }, + ['Output:Resend'] = { mode = 'n', key = '' }, + + -- Session window ("float" style) + ['Session:Toggle'] = { mode = 'n', key = 'ai' }, -- your chosen toggle + ['Session:Close'] = { mode = 'n', key = { '', 'Q' } }, + }, + + -- Optional diff display used by some tools/handlers + display = { + diff = { + layout = 'vertical', + opts = { + 'internal', + 'filler', + 'closeoff', + 'algorithm:patience', + 'followwrap', + 'linematch:120', + }, + provider = 'mini_diff', + disable_diagnostic = true, + }, + }, + + callbacks = { + on_response = function(resp) + local usage = resp and resp.usage + if usage then + vim.notify( + string.format( + 'LLM tokens — prompt: %d, completion: %d, total: %d', + usage.prompt_tokens or 0, + usage.completion_tokens or 0, + usage.total_tokens or 0 + ), + vim.log.levels.INFO + ) + end + end, + }, + + -- If you later add tools: + app_handler = { + -- Visual-select text -> run this -> output in a floating result window. + AskWithContext = { + handler = 'attach_to_chat_handler', + prompt = [[ + Answer the user’s question (likely code related) using the context very briefly and concisely: + ]], + opts = { + -- this is the key part: append the visual selection after the prompt + apply_visual_selection = true, -- described in docs for flexi_handler :contentReference[oaicite:2]{index=2} + is_codeblock = true, + enter_input = true, + enter_flexible_window = false, + --exit_on_move = true, + }, + }, + CodeExplain = { + handler = 'flexi_handler', + prompt = 'Explain the following code very briefly, please only return the explanation', + opts = { + enter_flexible_window = true, + }, + }, + }, + } + end, + keys = { + { 'ai', 'LLMSessionToggle', mode = 'n', silent = true, desc = 'LLM: toggle session' }, + { 'as', 'LLMSelectedTextHandler', mode = 'x', silent = true, desc = 'LLM: send selection' }, + -- If you add tools: + { 'ax', 'LLMAppHandler CodeExplain', mode = 'x', silent = true, desc = 'LLM tool: Explain' }, + { 'ai', 'LLMAppHandler AskWithContext', mode = 'x', silent = true, desc = 'LLM tool: Ask with context' }, + }, + }, + + { + 'MeanderingProgrammer/render-markdown.nvim', + dependencies = { + { + 'nvim-treesitter/nvim-treesitter', + branch = 'main', + config = function() + vim.api.nvim_create_autocmd('FileType', { + pattern = { 'llm', 'markdown' }, + callback = function() + vim.treesitter.start(0, 'markdown') + end, + }) + end, + }, + 'nvim-mini/mini.icons', + }, -- if you use standalone mini plugins + ft = { 'markdown', 'llm' }, + + config = function() + require('render-markdown').setup { + restart_highlighter = true, + heading = { + enabled = true, + sign = false, + position = 'overlay', -- inline | overlay + icons = { '󰎤 ', '󰎧 ', '󰎪 ', '󰎭 ', '󰎱 ', '󰎳 ' }, + signs = { '󰫎 ' }, + width = 'block', + left_margin = 0, + left_pad = 0, + right_pad = 0, + min_width = 0, + border = false, + border_virtual = false, + border_prefix = false, + above = '▄', + below = '▀', + backgrounds = {}, + foregrounds = { + 'RenderMarkdownH1', + 'RenderMarkdownH2', + 'RenderMarkdownH3', + 'RenderMarkdownH4', + 'RenderMarkdownH5', + 'RenderMarkdownH6', + }, + }, + dash = { + enabled = true, + icon = '─', + width = 0.5, + left_margin = 0.5, + highlight = 'RenderMarkdownDash', + }, + code = { style = 'normal' }, + } + end, + }, + -- DAP { 'mfussenegger/nvim-dap', @@ -1050,6 +1226,7 @@ local smear_profiles = { -- 1) Frost Mist eco_smear = { -- General (keep core behavior) + cursor_color = '#ffe6b2', smear_between_buffers = true, smear_between_neighbor_lines = true, min_horizontal_distance_smear = 1, -- reduces tiny smears @@ -1141,6 +1318,7 @@ local smear_profiles = { }, } +-- smear settings local smear_profile_order = { 'silver_blade', 'eco_smear', @@ -1168,6 +1346,8 @@ end, { return smear_profile_order end, }) +-- Apply a default on startup (pick one) +apply_smear_profile 'silver_blade' vim.api.nvim_create_user_command('SmearProfileNext', function() current_idx = (current_idx % #smear_profile_order) + 1 @@ -1183,8 +1363,6 @@ end, {}) vim.keymap.set('n', 'pn', 'SmearProfileNext', { desc = 'Smear profile: next' }) vim.keymap.set('n', 'pp', 'SmearProfilePrev', { desc = 'Smear profile: prev' }) --- Apply a default on startup (pick one) -apply_smear_profile 'silver_blade' -- ========================================= -- ============ END SMEAR PROFILE ========== -- ========================================= @@ -1231,14 +1409,14 @@ local function set_indent(ts) end vim.api.nvim_create_autocmd('FileType', { - pattern = { 'lua', 'javascript', 'typescript', 'tsx', 'json', 'yaml', 'toml', 'html', 'css', 'rust', 'c', 'cpp' }, + pattern = { 'lua', 'javascript', 'typescript', 'tsx', 'json', 'yaml', 'toml', 'html', 'css' }, callback = function() set_indent(2) end, }) vim.api.nvim_create_autocmd('FileType', { - pattern = { 'python', 'sh', 'bash', 'zsh', 'go' }, + pattern = { 'python', 'sh', 'bash', 'zsh', 'go', 'rust', 'cpp', 'c' }, callback = function() set_indent(4) end, @@ -1365,7 +1543,7 @@ vim.keymap.set('n', 'xw', 'TroubleToggle workspace_diagnostics' vim.keymap.set('n', 'xd', 'TroubleToggle document_diagnostics', { silent = true, noremap = true, desc = 'Document diagnostics (Trouble)' }) -- DAP -vim.keymap.set('n', '', ":lua require('dapui').toggle()", { desc = 'Toggle DAP UI' }) +vim.keymap.set('n', 'dap', ":lua require('dapui').toggle()", { desc = 'Toggle DAP UI' }) vim.keymap.set('n', 'dc', ":lua require('dap').continue()", { desc = 'DAP continue' }) vim.keymap.set('n', 'do', ":lua require('dap').step_over()", { desc = 'DAP step over' }) vim.keymap.set('n', 'di', ":lua require('dap').step_into()", { desc = 'DAP step into' }) @@ -1382,22 +1560,33 @@ vim.keymap.set('n', 'dt', ":lua require('dap').toggle_breakpoint()", vim.keymap.set('n', 'dm', ":lua require('dap-python').test_method()", { silent = true, noremap = true, desc = 'DAP test method' }) vim.keymap.set('n', 'df', ":lua require('dap-python').test_class()", { silent = true, noremap = true, desc = 'DAP test class' }) --- barbar -vim.keymap.set('n', '', 'BufferPrevious', { silent = true, noremap = true, desc = 'Previous buffer' }) -vim.keymap.set('n', '', 'BufferNext', { silent = true, noremap = true, desc = 'Next buffer' }) -vim.keymap.set('n', '', 'BufferClose', { silent = true, noremap = true, desc = 'Close buffer' }) +-- bufferline + +local opts = { noremap = true, silent = true } +-- KEYMAPS (Barbar) local opts = { noremap = true, silent = true } -vim.keymap.set('n', '', 'BufferLineGoToBuffer 1', vim.tbl_extend('force', opts, { desc = 'Go to buffer 1' })) -vim.keymap.set('n', '', 'BufferLineGoToBuffer 2', vim.tbl_extend('force', opts, { desc = 'Go to buffer 2' })) -vim.keymap.set('n', '', 'BufferLineGoToBuffer 3', vim.tbl_extend('force', opts, { desc = 'Go to buffer 3' })) -vim.keymap.set('n', '', 'BufferLineGoToBuffer 4', vim.tbl_extend('force', opts, { desc = 'Go to buffer 4' })) -vim.keymap.set('n', '', 'BufferLineGoToBuffer 5', vim.tbl_extend('force', opts, { desc = 'Go to buffer 5' })) -vim.keymap.set('n', '', 'BufferLineGoToBuffer 6', vim.tbl_extend('force', opts, { desc = 'Go to buffer 6' })) -vim.keymap.set('n', '', 'BufferLineGoToBuffer 7', vim.tbl_extend('force', opts, { desc = 'Go to buffer 7' })) -vim.keymap.set('n', '', 'BufferLineGoToBuffer 8', vim.tbl_extend('force', opts, { desc = 'Go to buffer 8' })) -vim.keymap.set('n', '', 'BufferLineGoToBuffer 9', vim.tbl_extend('force', opts, { desc = 'Go to buffer 9' })) + +vim.keymap.set('n', '', 'BufferGoto 1', vim.tbl_extend('force', opts, { desc = 'Go to buffer 1' })) +vim.keymap.set('n', '', 'BufferGoto 2', vim.tbl_extend('force', opts, { desc = 'Go to buffer 2' })) +vim.keymap.set('n', '', 'BufferGoto 3', vim.tbl_extend('force', opts, { desc = 'Go to buffer 3' })) +vim.keymap.set('n', '', 'BufferGoto 4', vim.tbl_extend('force', opts, { desc = 'Go to buffer 4' })) +vim.keymap.set('n', '', 'BufferGoto 5', vim.tbl_extend('force', opts, { desc = 'Go to buffer 5' })) +vim.keymap.set('n', '', 'BufferGoto 6', vim.tbl_extend('force', opts, { desc = 'Go to buffer 6' })) +vim.keymap.set('n', '', 'BufferGoto 7', vim.tbl_extend('force', opts, { desc = 'Go to buffer 7' })) +vim.keymap.set('n', '', 'BufferGoto 8', vim.tbl_extend('force', opts, { desc = 'Go to buffer 8' })) +vim.keymap.set('n', '', 'BufferGoto 9', vim.tbl_extend('force', opts, { desc = 'Go to buffer 9' })) vim.keymap.set('n', '', 'BufferLast', vim.tbl_extend('force', opts, { desc = 'Go to last buffer' })) +-- Close current buffer (Barbar) +vim.keymap.set('n', '', 'BufferClose', vim.tbl_extend('force', opts, { desc = 'Close buffer' })) + +-- Close current window/split +vim.keymap.set('n', '', 'close', vim.tbl_extend('force', opts, { desc = 'Close window' })) + +vim.keymap.set('n', '', 'BufferNext', { desc = 'Go to next buffer' }) +vim.keymap.set('n', '', 'BufferPrevious', { desc = 'Go to previous buffer' }) + +-- barbar colors -- quickfix vim.keymap.set('n', 'cn', ':cnext', { desc = 'Next quickfix item' }) @@ -1409,25 +1598,9 @@ vim.keymap.set('n', 'mp', ':MarkdownPreview', { desc = 'Markdown pre -- git vim.keymap.set('n', 'ga', ':Telescope coauthors', { desc = 'Select git co-authors' }) --- AI model switching -vim.keymap.set('n', 'an', function() - _G.chatgpt_model = 'gpt-5-nano' - print 'ChatGPT → gpt-5-nano' -end, { desc = 'ChatGPT model: gpt-5-nano' }) - -vim.keymap.set('n', 'ac', function() - _G.chatgpt_model = 'gpt-5.1-codex-mini' - print 'ChatGPT → gpt-5.1-codex-mini' -end, { desc = 'ChatGPT model: gpt-5.1-codex-mini' }) - -vim.keymap.set('n', 'ai', 'ChatGPT', { desc = 'Open ChatGPT prompt' }) - -- delete backwards vim.keymap.set({ 'i', 'c' }, '', '', { noremap = true, desc = 'Delete previous word' }) -vim.keymap.set('n', '', 'BufferLineCycleNext', { desc = 'Go to next tab' }) -vim.keymap.set('n', '', 'BufferLineCyclePrev', { desc = 'Go backwards a tab' }) - vim.keymap.set('n', 'tc', ':tabclose', { desc = 'Close current tab' }) vim.keymap.set('n', 'fk', ':FloatermKill!', { desc = 'Kill all floaterm terminals' }) vim.keymap.set('x', 'S', '(nvim-surround-visual)', { remap = true }, { desc = 'Surround selected text' }) @@ -1462,9 +1635,9 @@ _G.toggle_neotree = toggle_neotree vim.api.nvim_set_keymap('n', '', ':lua toggle_neotree()', { noremap = true, silent = true }) -- Floaterm -vim.api.nvim_set_keymap('n', '', ':FloatermToggle', { noremap = true }) -vim.api.nvim_set_keymap('i', '', ':FloatermToggle', { noremap = true }) -vim.api.nvim_set_keymap('t', '', ':FloatermToggle', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', ':FloatermToggle', { noremap = true }) +vim.api.nvim_set_keymap('i', '', ':FloatermToggle', { noremap = true }) +vim.api.nvim_set_keymap('t', '', ':FloatermToggle', { noremap = true, silent = true }) -- Comment.nvim keymaps vim.api.nvim_set_keymap('n', '', 'lua require("Comment.api").toggle.linewise.current()', { noremap = true, silent = true }) @@ -1478,3 +1651,7 @@ vim.keymap.set('n', 'ga', ':Telescope coauthors') -- install treesitter parsers require('nvim-treesitter').install { 'c', 'rust', 'gdscript', 'c#' } + +-- LSP basics +vim.keymap.set('n', '', vim.lsp.buf.rename, { silent = true, desc = 'LSP: Rename' }) +vim.keymap.set('n', '', vim.lsp.buf.references, { silent = true, desc = 'LSP: References' }) diff --git a/lua/bootstrap/deps.lua b/lua/bootstrap/deps.lua new file mode 100644 index 00000000000..f6ad05b1796 --- /dev/null +++ b/lua/bootstrap/deps.lua @@ -0,0 +1,33 @@ +-- lua/bootstrap/deps.lua +-- System-level deps for this config (Arch / pacman names) + +return { + -- bootstrap + "neovim", + "git", + + -- telescope / grep + "ripgrep", + "fd", + + -- builds native plugins (telescope-fzf-native, treesitter parsers, etc.) + "base-devel", + + -- clipboard (Wayland) + "wl-clipboard", + -- X11 alternative (optional): "xclip", + + -- markdown-preview.nvim build/runtime + "nodejs", + "npm", + + -- toggleterm custom commands + "lazygit", + + -- neo-tree external opener + "imv", + + -- treesitter + "tree-sitter-cli", +} + diff --git a/lua/bootstrap/pacman.lua b/lua/bootstrap/pacman.lua new file mode 100644 index 00000000000..2dbbf12390e --- /dev/null +++ b/lua/bootstrap/pacman.lua @@ -0,0 +1,111 @@ +-- ~/.config/nvim/lua/bootstrap/pacman.lua +-- Fix1: run pacman inside a Neovim terminal so sudo has a real TTY. + +local M = {} + +local function has_exe(exe) + return vim.fn.executable(exe) == 1 +end + +local function pacman_has(pkg) + local out = vim.fn.system({ "pacman", "-Qi", pkg }) + return vim.v.shell_error == 0 and out ~= nil and out ~= "" +end + +local function missing_pkgs(pkgs) + local missing = {} + for _, p in ipairs(pkgs) do + if not pacman_has(p) then + table.insert(missing, p) + end + end + return missing +end + +local function shell_escape_arg(s) + -- minimal quoting for a shell command string + return "'" .. tostring(s):gsub("'", [['"'"']]) .. "'" +end + +local function open_install_terminal(pkgs) + if #pkgs == 0 then + return true + end + + if not has_exe("sudo") then + vim.notify("Missing `sudo`; cannot auto-install pacman deps.", vim.log.levels.ERROR) + return false + end + + -- Build a single shell command so sudo prompts normally. + local parts = { "sudo", "pacman", "-S", "--needed" } + for _, p in ipairs(pkgs) do + table.insert(parts, shell_escape_arg(p)) + end + local cmd = table.concat(parts, " ") + + vim.notify("Opening terminal to install:\n" .. table.concat(pkgs, ", "), vim.log.levels.WARN) + + -- Open a terminal split and run the command. User can enter sudo password normally. + vim.cmd("botright 15split") + vim.cmd("terminal " .. cmd) + vim.cmd("startinsert") + + return true +end + +function M.check() + if not has_exe("pacman") then + vim.notify("pacman not found. This bootstrap is Arch-specific.", vim.log.levels.WARN) + return {} + end + local deps = require("bootstrap.deps") + return missing_pkgs(deps) +end + +function M.install(opts) + opts = opts or {} + local miss = M.check() + if #miss == 0 then + if not opts.quiet then + vim.notify("All system deps already installed.", vim.log.levels.INFO) + end + return true + end + + local prompt = "Missing system deps:\n\n" + .. table.concat(miss, "\n") + .. "\n\nOpen a terminal and run sudo pacman to install them?" + + local ok = true + if not opts.force then + ok = (vim.fn.confirm(prompt, "&Yes\n&No", 1) == 1) + end + if not ok then + return false + end + + return open_install_terminal(miss) +end + +-- Commands +vim.api.nvim_create_user_command("DepsCheck", function() + local miss = M.check() + if #miss == 0 then + vim.notify("DepsCheck: OK (no missing packages).", vim.log.levels.INFO) + else + vim.notify("DepsCheck missing:\n" .. table.concat(miss, ", "), vim.log.levels.WARN) + end +end, {}) + +vim.api.nvim_create_user_command("DepsInstall", function() + M.install({ force = true }) +end, {}) + +-- Run once per session (prompt-based) +if vim.g.__deps_bootstrap_ran ~= true then + vim.g.__deps_bootstrap_ran = true + M.install({ force = false, quiet = true }) +end + +return M From ca178b641d7e3c061f597f865fc9ec2d81c7cf15 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Sat, 3 Jan 2026 23:59:33 -1000 Subject: [PATCH 20/22] neoscroll and keybindings --- init.lua | 109 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 26 deletions(-) diff --git a/init.lua b/init.lua index 523c4fda866..d19f6cb93ab 100644 --- a/init.lua +++ b/init.lua @@ -2,7 +2,7 @@ vim.g.maplocalleader = ' ' vim.g.mapleader = ' ' -- install deps if need to -require("bootstrap.pacman") +require 'bootstrap.pacman' -- ========================= -- Lazy.nvim bootstrap @@ -34,6 +34,61 @@ require('lazy').setup({ { 'numToStr/Comment.nvim', opts = {} }, + { + 'karb94/neoscroll.nvim', + opts = {}, + config = function() + local neoscroll = require 'neoscroll' + + neoscroll.setup { + -- remove / from defaults so your custom maps win + mappings = { + '', + '', + '', + '', + 'zt', + 'zz', + 'zb', + }, + hide_cursor = true, -- Hide cursor while scrolling + stop_eof = true, -- Stop at when scrolling downwards + respect_scrolloff = true, -- Stop scrolling when the cursor reaches the scrolloff margin of the file + cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further + duration_multiplier = 0.3, -- Global duration multiplier + easing = 'quadratic', -- Default easing function + pre_hook = function(info) + if info == 'center' then + vim.cmd 'normal! M' + end + end, + post_hook = nil, + } + local function near_file_edge() + local line = vim.api.nvim_win_get_cursor(0)[1] + local last = vim.api.nvim_buf_line_count(0) + local so = vim.wo.scrolloff + return line <= so + 1 or line >= last - so + end + + local modes = { 'n', 'v', 'x' } + + vim.keymap.set(modes, '', function() + neoscroll.ctrl_d { duration = 300 } + if not near_file_edge() then + vim.cmd 'normal! M' + end + end) + + vim.keymap.set(modes, '', function() + neoscroll.ctrl_u { duration = 300 } + if not near_file_edge() then + vim.cmd 'normal! M' + end + end) + end, + }, + { 'nvim-treesitter/nvim-treesitter', lazy = false, @@ -53,7 +108,9 @@ require('lazy').setup({ 'yaml', 'toml', }, - highlight = { enable = true }, + highlight = { + enable = true, + }, }, }, @@ -126,17 +183,6 @@ require('lazy').setup({ end, }, - -- Colors - { - 'folke/tokyonight.nvim', - lazy = false, - priority = 1000, - config = function() - vim.cmd.colorscheme 'gruvbox-material' - vim.cmd.hi 'Comment gui=none' - end, - }, - { 'sphamba/smear-cursor.nvim', opts = { @@ -191,7 +237,7 @@ require('lazy').setup({ system_open = function(state) local node = state.tree:get_node() local path = node:get_id() -- absolute path - vim.fn.jobstart({ 'imv', path }, { detach = true }) + vim.fn.jobstart({ 'xdg-open', path }, { detach = true }) end, }, window = { @@ -794,6 +840,7 @@ require('lazy').setup({ return { 'isort', 'black' } end, yaml = { 'prettier' }, + rust = { 'rustfmt' }, ['*'] = { 'injected' }, }, ignore_errors = true, @@ -1465,11 +1512,11 @@ vim.api.nvim_create_autocmd({ 'BufLeave', 'InsertEnter', 'FocusLost' }, { -- Keymaps (treesitter keymaps removed) -- ========================= --- scrolling / search centering -vim.keymap.set('n', '', 'zz', { desc = 'Scroll down and center cursor' }) -vim.keymap.set('n', '', 'zz', { desc = 'Scroll up and center cursor' }) -vim.keymap.set('n', 'n', 'nzzzv', { desc = 'Next search result and center' }) -vim.keymap.set('n', 'N', 'Nzzzv', { desc = 'Previous search result and center' }) +-- scrolling / search centering, disabled for neoscroll +-- vim.keymap.set('n', '', 'zz', { desc = 'Scroll down and center cursor' }) +-- vim.keymap.set('n', '', 'zz', { desc = 'Scroll up and center cursor' }) +-- vim.keymap.set('n', 'n', 'nzzzv', { desc = 'Next search result and center' }) +-- vim.keymap.set('n', 'N', 'Nzzzv', { desc = 'Previous search result and center' }) -- move selected lines vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move selection down' }) @@ -1497,6 +1544,7 @@ vim.keymap.set('n', 'de', vim.diagnostic.enable, { desc = 'Enable diagno vim.keymap.set('n', 'cw', ':cd %:p:h:pwd', { desc = 'cd to current file directory' }) vim.keymap.set('n', '', '', { noremap = true, desc = 'Jump forward in jumplist' }) vim.keymap.set('n', '', ':write', { desc = 'Save file' }) +vim.keymap.set('i', '', ':write', { desc = 'Save file' }) vim.keymap.set('n', 'cd', ':ToggleAutoComplete', { desc = 'Toggle autocomplete' }) vim.keymap.set('n', 'ce', ':ToggleAutoComplete', { desc = 'Toggle autocomplete (alias)' }) @@ -1615,10 +1663,6 @@ vim.keymap.set('n', '', 'wqa') vim.keymap.set('n', 'sv', 'vsplit') vim.keymap.set('n', 'sh', 'split') --- signature help -vim.api.nvim_set_keymap('i', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) - -- toggle neotree local function toggle_neotree() local manager = require 'neo-tree.sources.manager' @@ -1650,8 +1694,21 @@ vim.api.nvim_set_keymap('i', '', '', { noremap = true }) vim.keymap.set('n', 'ga', ':Telescope coauthors') -- install treesitter parsers -require('nvim-treesitter').install { 'c', 'rust', 'gdscript', 'c#' } +require('nvim-treesitter').install { 'c', 'rust', 'gdscript', 'c_sharp' } --- LSP basics +-- ======== LSP settings =========== +-- signature help +vim.api.nvim_set_keymap('i', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('i', '', 'lua vim.lsp.buf.hover()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua vim.lsp.buf.hover()', { noremap = true, silent = true }) +-- code actions (normal + insert) +vim.keymap.set({ 'n', 'i' }, '', vim.lsp.buf.code_action, { silent = true, desc = 'Code Action' }) +-- rename bindings vim.keymap.set('n', '', vim.lsp.buf.rename, { silent = true, desc = 'LSP: Rename' }) -vim.keymap.set('n', '', vim.lsp.buf.references, { silent = true, desc = 'LSP: References' }) +vim.keymap.set('n', '', vim.lsp.buf.definition, { silent = true, desc = 'LSP: Go To Defintion' }) + +-- put after colorscheme load +vim.api.nvim_set_hl(0, '@lsp.type.typeAlias', { link = 'Type' }) +vim.api.nvim_set_hl(0, '@lsp.type.type', { link = 'Type' }) +vim.api.nvim_set_hl(0, '@lsp.type.struct', { link = 'Type' }) From 9e9f1f41392653a941f76184ce062117c243fa0e Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Sun, 4 Jan 2026 00:11:26 -1000 Subject: [PATCH 21/22] fixed dependencies --- lua/bootstrap/deps.lua | 4 ++-- package-lock.json | 6 ++++++ package.json | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/lua/bootstrap/deps.lua b/lua/bootstrap/deps.lua index f6ad05b1796..d80c82fba39 100644 --- a/lua/bootstrap/deps.lua +++ b/lua/bootstrap/deps.lua @@ -27,7 +27,7 @@ return { -- neo-tree external opener "imv", - -- treesitter - "tree-sitter-cli", + -- -- treesitter + -- "tree-sitter-cli", } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000000..b7ea3d5e12b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "nvim", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/package.json b/package.json new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +{} From d701e7cd8bdbb435795f2d2d57f449cb397b0b99 Mon Sep 17 00:00:00 2001 From: RiverMatsumoto Date: Tue, 30 Jun 2026 00:38:54 -1000 Subject: [PATCH 22/22] modernize config --- .github/workflows/ci.yml | 24 +++ .github/workflows/update-plugins.yml | 52 ++++++ .gitignore | 3 +- .nvim-version | 1 + README.md | 240 ++++----------------------- init.lua | 222 ++++++++++++------------- lazy-lock.json | 62 +++++++ lua/bootstrap/pacman.lua | 111 ------------- scripts/nvim-test.sh | 39 +++++ 9 files changed, 317 insertions(+), 437 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/update-plugins.yml create mode 100644 .nvim-version create mode 100644 lazy-lock.json delete mode 100644 lua/bootstrap/pacman.lua create mode 100755 scripts/nvim-test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..dc8f9dc9fe3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: Neovim config + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + smoke-test: + runs-on: ubuntu-24.04 + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y build-essential curl git ripgrep + - name: Install Neovim 0.12.2 + run: | + curl -fL https://github.com/neovim/neovim/releases/download/v0.12.2/nvim-linux-x86_64.tar.gz -o /tmp/nvim.tar.gz + tar -xzf /tmp/nvim.tar.gz -C /tmp + echo "/tmp/nvim-linux-x86_64/bin" >> "$GITHUB_PATH" + - name: Restore locked plugins and start Neovim + run: scripts/nvim-test.sh restore diff --git a/.github/workflows/update-plugins.yml b/.github/workflows/update-plugins.yml new file mode 100644 index 00000000000..a54f2fd832e --- /dev/null +++ b/.github/workflows/update-plugins.yml @@ -0,0 +1,52 @@ +name: Update locked plugins + +on: + schedule: + - cron: '17 7 * * 1' + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + update: + runs-on: ubuntu-24.04 + timeout-minutes: 20 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y build-essential curl git ripgrep + - name: Install Neovim 0.12.2 + run: | + curl -fL https://github.com/neovim/neovim/releases/download/v0.12.2/nvim-linux-x86_64.tar.gz -o /tmp/nvim.tar.gz + tar -xzf /tmp/nvim.tar.gz -C /tmp + echo "/tmp/nvim-linux-x86_64/bin" >> "$GITHUB_PATH" + - name: Update plugins and smoke test the result + run: scripts/nvim-test.sh update + - name: Open or refresh the update pull request + env: + GH_TOKEN: ${{ github.token }} + run: | + if git diff --quiet -- lazy-lock.json; then + echo "Plugin lockfile is already current." + exit 0 + fi + + branch=automation/plugin-updates + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git fetch origin "$branch" || true + git switch -C "$branch" + git add lazy-lock.json + git commit -m "chore: update locked plugins" + git push --force-with-lease origin "$branch" + + gh pr create \ + --base "${GITHUB_REF_NAME}" \ + --head "$branch" \ + --title "chore: update locked Neovim plugins" \ + --body "Automated weekly plugin update. Merge only after the Neovim config check passes." \ + || gh pr edit "$branch" --body "Automated weekly plugin update. Merge only after the Neovim config check passes." diff --git a/.gitignore b/.gitignore index 005b535b606..f7ba19154cb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ test.sh nvim spell/ -lazy-lock.json +# The plugin lockfile is intentionally committed. It is the rollback point for +# safe updates and must not be ignored. diff --git a/.nvim-version b/.nvim-version new file mode 100644 index 00000000000..60d68b2300b --- /dev/null +++ b/.nvim-version @@ -0,0 +1 @@ +v0.12.2 diff --git a/README.md b/README.md index bb20f57b891..de239a73469 100644 --- a/README.md +++ b/README.md @@ -1,222 +1,50 @@ -# kickstart.nvim +# River's Neovim config -# install: -`git clone https://github.com/RiverMatsumoto/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim` +This configuration targets **Neovim 0.12.x** and pins the complete plugin graph +in `lazy-lock.json`. Normal editor startup never updates plugins. A weekly GitHub +Actions job proposes lockfile updates in a pull request, and the same isolated +smoke test runs on every push and pull request. -## Introduction +That gives updates a rollback point and keeps upstream breaking changes out of +the working editor until they pass CI. It cannot make arbitrary upstream +changes risk-free, but it turns them into reviewed, reversible changes instead +of surprise startup failures. -A starting point for Neovim that is: +## Install -* Small -* Single-file -* Completely Documented - -**NOT** a Neovim distribution, but instead a starting point for your configuration. - -## Installation - -### Install Neovim - -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. - -### Install External Dependencies - -> **NOTE** -> [Backup](#FAQ) your previous configuration (if any exists) - -External Requirements: -- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) -- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) -- Language Setup: - - If want to write Typescript, you need `npm` - - If want to write Golang, you will need `go` - - etc. - -> **NOTE** -> See [Windows Installation](#Windows-Installation) to double check any additional Windows notes - -Neovim's configurations are located under the following paths, depending on your OS: - -| OS | PATH | -| :- | :--- | -| Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` | -| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` | - -### Install Kickstart - -Clone kickstart.nvim: - -
Linux and Mac - -```sh -git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim -``` - -
- -
Windows - -If you're using `cmd.exe`: - -``` -git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ -``` - -If you're using `powershell.exe` - -``` -git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ -``` - -
- -### Post Installation - -Start Neovim +Required: Neovim 0.12.x, Git, a C compiler, `make`, `unzip`, and `ripgrep`. A Nerd +Font is recommended. Language servers, formatters, and debuggers are installed +through Mason on first interactive startup. ```sh +git clone https://github.com/RiverMatsumoto/kickstart.nvim.git \ + "${XDG_CONFIG_HOME:-$HOME/.config}/nvim" nvim ``` -That's it! Lazy will install all the plugins you have. Use `:Lazy` to view -current plugin status. - -Read through the `init.lua` file in your configuration folder for more -information about extending and exploring Neovim. - -### Getting Started - -See [Effective Neovim: Instant IDE](https://youtu.be/stqUbv-5u2s), covering the -previous version. Note: The install via init.lua is outdated, please follow the -install instructions in this file instead. An updated video is coming soon. +To try it without replacing another config: -### Recommended Steps - -[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo -(so that you have your own copy that you can modify) and then installing you -can install to your machine using the methods above. - -> **NOTE** -> Your fork's url will be something like this: `https://github.com//kickstart.nvim.git` - -#### Examples of adding popularly requested plugins - -NOTE: You'll need to uncomment the line in the init.lua that turns on loading custom plugins. - -
- Adding autopairs - -This will automatically install [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs) and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). - -In the file: `lua/custom/plugins/autopairs.lua`, add: - -```lua --- File: lua/custom/plugins/autopairs.lua - -return { - "windwp/nvim-autopairs", - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require("nvim-autopairs").setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require('nvim-autopairs.completion.cmp') - local cmp = require('cmp') - cmp.event:on( - 'confirm_done', - cmp_autopairs.on_confirm_done() - ) - end, -} -``` - -
-
- Adding a file tree plugin - -This will install the tree plugin and add the command `:Neotree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. - -In the file: `lua/custom/plugins/filetree.lua`, add: - -```lua --- Unless you are still migrating, remove the deprecated commands from v1.x -vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) - -return { - "nvim-neo-tree/neo-tree.nvim", - version = "*", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - }, - config = function () - require('neo-tree').setup {} - end, -} -``` - -
- -### FAQ - -* What should I do if I already have a pre-existing neovim configuration? - * You should back it up, then delete all files associated with it. - * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` -* Can I keep my existing configuration in parallel to kickstart? - * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` to maintain multiple configurations. For example you can install the kickstart configuration in `~/.config/nvim-kickstart` and create an alias: - ``` - alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim' - ``` - When you run Neovim using `nvim-kickstart` alias it will use the alternative config directory and the matching local directory `~/.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://github.com/folke/lazy.nvim#-uninstalling) information -* 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 `git clone` as a basis for their own. - As you progress in learning Neovim and Lua, you might consider splitting `init.lua` - into smaller parts. A fork of kickstart that does this while maintaining the exact - same functionality is available here: - * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) - * Discussions on this topic can be found here: - * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) - * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) - -### Windows Installation - -Installation may require installing build tools, and updating the run command for `telescope-fzf-native` - -See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) - -This requires: - -- Install CMake, and the Microsoft C++ Build Tools on Windows - -```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' } +```sh +git clone https://github.com/RiverMatsumoto/kickstart.nvim.git ~/.config/nvim-river +NVIM_APPNAME=nvim-river nvim ``` -Alternatively one can install gcc and make which don't require changing the config, -the easiest way is to use choco: +## Updates -1. install [chocolatey](https://chocolatey.org/install) -either follow the instructions on the page or use winget, -run in cmd as **admin**: -``` -winget install --accept-source-agreements chocolatey.chocolatey -``` - -2. install all requirements using choco, exit previous cmd and -open a new one so that choco path is set, run in cmd as **admin**: -``` -choco install -y neovim git ripgrep wget fd unzip gzip mingw make -``` +- Do not use `:Lazy update` on the main branch for routine updates. +- Merge the automated `chore: update locked Neovim plugins` pull request after + its checks pass. +- To test an update locally, run `scripts/nvim-test.sh update`. This uses + isolated data/cache directories and changes only `lazy-lock.json`. +- Restore the committed versions at any time with `:Lazy restore`. -Then continue with the [Install Kickstart](#Install-Kickstart) step. +The Neovim version is pinned in `.nvim-version`. Upgrade Neovim separately from +plugin updates so failures have one clear cause. +## Design choices ->>>>>>> afed39f595301147188dac2c5453bce8515d5325 +The version guard, modular setup conventions, native `vim.lsp.config` API, and +current Treesitter `main` API follow the useful compatibility patterns in +[jdhao/nvim-config](https://github.com/jdhao/nvim-config). The system package +installer is intentionally not run from Neovim; editor startup should never ask +for administrator privileges or mutate the operating system. diff --git a/init.lua b/init.lua index d19f6cb93ab..81872dc77cc 100644 --- a/init.lua +++ b/init.lua @@ -1,22 +1,29 @@ vim.g.maplocalleader = ' ' vim.g.mapleader = ' ' --- install deps if need to -require 'bootstrap.pacman' +vim.loader.enable() + +local version = vim.version() +if version.major ~= 0 or version.minor ~= 12 then + error(('This config supports Neovim 0.12.x (found %s)'):format(tostring(version))) +end -- ========================= -- Lazy.nvim bootstrap -- ========================= local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.loop.fs_stat(lazypath) then - vim.fn.system { +if not vim.uv.fs_stat(lazypath) then + local result = vim.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath, - } + }, { text = true }):wait() + if result.code ~= 0 then + error(('Unable to install lazy.nvim:\n%s'):format(result.stderr or 'unknown error')) + end end vim.opt.rtp:prepend(lazypath) @@ -91,43 +98,46 @@ require('lazy').setup({ { 'nvim-treesitter/nvim-treesitter', + branch = 'main', lazy = false, build = ':TSUpdate', - opts = { - ensure_installed = { - 'lua', - 'rust', - 'python', - 'javascript', - 'typescript', + }, + + { + 'MeanderingProgrammer/treesitter-modules.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + config = function() + local parsers = { + 'bash', 'c', 'c_sharp', 'cpp', - 'bash', + 'gdscript', + 'javascript', 'json', - 'yaml', + 'lua', + 'markdown', + 'python', + 'rust', 'toml', - }, - highlight = { - enable = true, - }, - }, - }, + 'typescript', + 'yaml', + } - { - 'MeanderingProgrammer/treesitter-modules.nvim', - dependencies = { 'nvim-treesitter/nvim-treesitter' }, - opts = { - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', -- Alt+Space - node_incremental = '', -- Alt+Space (expand) - node_decremental = '', -- Alt+Backspace (shrink) - scope_incremental = '', -- Alt+Shift+Space (scope expand) + require('treesitter-modules').setup { + ensure_installed = vim.env.NVIM_SKIP_TOOL_INSTALL == '1' and {} or parsers, + highlight = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + node_decremental = '', + scope_incremental = '', + }, }, - }, - }, + } + end, }, 'rhysd/git-messenger.vim', @@ -404,34 +414,6 @@ require('lazy').setup({ end, }, - -- Tooling installer - { - 'WhoIsSethDaniel/mason-tool-installer.nvim', - dependencies = { 'williamboman/mason.nvim' }, - opts = { - ensure_installed = { - 'clangd', - 'clang-format', - 'codelldb', - 'cpplint', - 'cpptools', - 'csharpier', - 'csharp-language-server', - 'lua-language-server', - 'netcoredbg', - 'omnisharp', - 'omnisharp-mono', - 'prettier', - 'ruff', - 'rust-analyzer', - 'sonarlint-language-server', - 'stylua', - }, - auto_update = false, - run_on_start = true, - }, - }, - -- Terminal UX { 'akinsho/toggleterm.nvim', @@ -459,7 +441,7 @@ require('lazy').setup({ function _G.set_terminal_keymaps() local opts = { noremap = true } - vim.diagnostic.disable(0) + vim.diagnostic.enable(false, { bufnr = 0 }) vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) end vim.cmd 'autocmd! TermOpen term://* lua set_terminal_keymaps()' @@ -473,7 +455,7 @@ require('lazy').setup({ float_opts = { width = vim.o.columns, height = vim.o.lines }, on_open = function(term) vim.cmd 'startinsert!' - vim.diagnostic.disable(0) + vim.diagnostic.enable(false, { bufnr = 0 }) vim.api.nvim_buf_set_keymap(0, 't', '', 'close', { silent = false, noremap = true }) if vim.fn.mapcheck('', 't') ~= '' then vim.api.nvim_buf_del_keymap(term.bufnr, 't', '') @@ -592,8 +574,8 @@ require('lazy').setup({ { 'neovim/nvim-lspconfig', dependencies = { - { 'williamboman/mason.nvim', config = true }, - 'williamboman/mason-lspconfig.nvim', + { 'mason-org/mason.nvim', config = true }, + 'mason-org/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', { 'j-hui/fidget.nvim', @@ -660,12 +642,14 @@ require('lazy').setup({ }, }, pyright = { - python = { - analysis = { - autoSearchPaths = true, - diagnosticMode = 'openFilesOnly', - useLibraryCodeForTypes = true, - reportDuplicateImport = true, + settings = { + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = 'openFilesOnly', + useLibraryCodeForTypes = true, + reportDuplicateImport = true, + }, }, }, }, @@ -692,30 +676,38 @@ require('lazy').setup({ capabilities.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true } require('mason').setup { ui = { border = 'rounded' } } + for server_name, server in pairs(servers) do + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + vim.lsp.config(server_name, server) + end + require('mason-lspconfig').setup { - handlers = { - function(server_name) - local server = servers[server_name] or {} - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, + ensure_installed = vim.env.NVIM_SKIP_TOOL_INSTALL == '1' and {} or vim.tbl_keys(servers), + automatic_enable = true, } require('mason-tool-installer').setup { ensure_installed = { 'clangd', + 'clang-format', 'lua_ls', 'pyright', 'ruff', 'codelldb', 'cpptools', 'cpplint', + 'csharpier', + 'csharp-language-server', + 'netcoredbg', + 'omnisharp', + 'omnisharp-mono', + 'rust-analyzer', + 'sonarlint-language-server', 'stylua', 'prettier', }, auto_update = false, - run_on_start = true, + run_on_start = vim.env.NVIM_SKIP_TOOL_INSTALL ~= '1', start_delay = 3000, debounce_hours = 5, } @@ -801,25 +793,18 @@ require('lazy').setup({ }), }) - require('lspconfig.ui.windows').default_options.border = 'rounded' - vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' }) - vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded' }) - - local diagnostic_signs = { - { name = 'DiagnosticSignError', text = ' ' }, - { name = 'DiagnosticSignWarn', text = ' ' }, - { name = 'DiagnosticSignHint', text = ' ' }, - { name = 'DiagnosticSignInfo', text = ' ' }, - } - for _, sign in ipairs(diagnostic_signs) do - vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name }) - end - vim.diagnostic.config { virtual_text = { prefix = '●' }, severity_sort = true, float = { source = 'always' }, - signs = true, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = ' ', + [vim.diagnostic.severity.WARN] = ' ', + [vim.diagnostic.severity.HINT] = ' ', + [vim.diagnostic.severity.INFO] = ' ', + }, + }, } end, }, @@ -862,11 +847,11 @@ require('lazy').setup({ ['end'] = { args.line2, end_line:len() }, } end - require('conform').format { async = true, lsp_fallback = true, range = range } + require('conform').format { async = true, lsp_format = 'fallback', range = range } end, { range = true }) vim.keymap.set('', 'fa', function() - require('conform').format { async = true, lsp_fallback = true } + require('conform').format { async = true, lsp_format = 'fallback' } end, { desc = '[F]ormat [a]ll' }) end, }, @@ -1032,18 +1017,7 @@ require('lazy').setup({ { 'MeanderingProgrammer/render-markdown.nvim', dependencies = { - { - 'nvim-treesitter/nvim-treesitter', - branch = 'main', - config = function() - vim.api.nvim_create_autocmd('FileType', { - pattern = { 'llm', 'markdown' }, - callback = function() - vim.treesitter.start(0, 'markdown') - end, - }) - end, - }, + 'nvim-treesitter/nvim-treesitter', 'nvim-mini/mini.icons', }, -- if you use standalone mini plugins ft = { 'markdown', 'llm' }, @@ -1170,7 +1144,12 @@ require('lazy').setup({ vim.api.nvim_create_user_command('DapResetUI', ":lua require('dapui').open({reset = true})", { desc = 'Reset DAP UI Layout' }) end, }, -}, {}) +}, { + lockfile = vim.fn.stdpath 'config' .. '/lazy-lock.json', + checker = { enabled = false }, + change_detection = { enabled = false, notify = false }, + install = { colorscheme = { 'gruvbox-material', 'habamax' } }, +}) -- ========================================= -- ============ START SMEAR PROFILE ======== @@ -1533,12 +1512,20 @@ vim.keymap.set('x', 'p', [["_dP]], { desc = 'Paste without overwriting r vim.keymap.set('n', 'ya', ':%y+', { desc = 'Yank entire buffer to clipboard' }) -- diagnostics -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Previous diagnostic' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Next diagnostic' }) +vim.keymap.set('n', '[d', function() + vim.diagnostic.jump { count = -1, float = true } +end, { desc = 'Previous diagnostic' }) +vim.keymap.set('n', ']d', function() + vim.diagnostic.jump { count = 1, float = true } +end, { desc = 'Next diagnostic' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic under cursor' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Diagnostics to loclist' }) -vim.keymap.set('n', 'dd', vim.diagnostic.disable, { desc = 'Disable diagnostics' }) -vim.keymap.set('n', 'de', vim.diagnostic.enable, { desc = 'Enable diagnostics' }) +vim.keymap.set('n', 'dd', function() + vim.diagnostic.enable(false) +end, { desc = 'Disable diagnostics' }) +vim.keymap.set('n', 'de', function() + vim.diagnostic.enable(true) +end, { desc = 'Enable diagnostics' }) -- misc vim.keymap.set('n', 'cw', ':cd %:p:h:pwd', { desc = 'cd to current file directory' }) @@ -1586,9 +1573,9 @@ vim.keymap.set('n', 'me', ':!chmod +x %:p', { desc = 'Make file exec vim.keymap.set('n', 'P', require('spectre').open, { desc = 'Open Spectre search/replace' }) -- Trouble -vim.keymap.set('n', 'xx', 'TroubleToggle', { silent = true, noremap = true, desc = 'Toggle Trouble' }) -vim.keymap.set('n', 'xw', 'TroubleToggle workspace_diagnostics', { silent = true, noremap = true, desc = 'Workspace diagnostics (Trouble)' }) -vim.keymap.set('n', 'xd', 'TroubleToggle document_diagnostics', { silent = true, noremap = true, desc = 'Document diagnostics (Trouble)' }) +vim.keymap.set('n', 'xx', 'Trouble diagnostics toggle', { silent = true, desc = 'Toggle Trouble diagnostics' }) +vim.keymap.set('n', 'xw', 'Trouble diagnostics toggle', { silent = true, desc = 'Workspace diagnostics (Trouble)' }) +vim.keymap.set('n', 'xd', 'Trouble diagnostics toggle filter.buf=0', { silent = true, desc = 'Document diagnostics (Trouble)' }) -- DAP vim.keymap.set('n', 'dap', ":lua require('dapui').toggle()", { desc = 'Toggle DAP UI' }) @@ -1693,9 +1680,6 @@ vim.api.nvim_set_keymap('i', '', '', { noremap = true }) -- git coauthors vim.keymap.set('n', 'ga', ':Telescope coauthors') --- install treesitter parsers -require('nvim-treesitter').install { 'c', 'rust', 'gdscript', 'c_sharp' } - -- ======== LSP settings =========== -- signature help vim.api.nvim_set_keymap('i', '', 'lua vim.lsp.buf.signature_help()', { noremap = true, silent = true }) diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000000..0902ef6795c --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,62 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "0abc8f390b278c3b4aabc4c004ac8a088b65cf24" }, + "barbar.nvim": { "branch": "master", "commit": "337ecfadb8bf005050990bf2f624dc4fc828dabd" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conflict-marker.vim": { "branch": "master", "commit": "62742b2ffe7a433988759c67b5c5a22eff74a14b" }, + "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, + "fidget.nvim": { "branch": "main", "commit": "6f793b2bcd2d35e201c09520f698bb763220908a" }, + "flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" }, + "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, + "git-coauthors.nvim": { "branch": "main", "commit": "a31352a63a99e0aff613aa7961d4f5fa955b3d87" }, + "git-messenger.vim": { "branch": "master", "commit": "fd124457378a295a5d1036af4954b35d6b807385" }, + "gitsigns.nvim": { "branch": "main", "commit": "2038c666bd9d8a0b7349a0b6ee00dc83104b9ecf" }, + "gruvbox-material": { "branch": "master", "commit": "5b45305389cac6db2dba0eff338fcae19b867703" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, + "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, + "llm.nvim": { "branch": "main", "commit": "a36ef8065fd97e774c90dfde63ff5cfb732958ec" }, + "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "47059d71b42d74b0a1e9f61c1d99d301039c3b5b" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, + "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, + "mini.icons": { "branch": "main", "commit": "e56797f90192d81f1fda02e662fc3e8e3d775027" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "ebd66767191714e008ce73b769518a763ff31bdc" }, + "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, + "neoscroll.nvim": { "branch": "master", "commit": "c8d29979cb0cb3a2437a8e0ae683fd82f340d3b8" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, + "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, + "nvim-dap": { "branch": "master", "commit": "9e848e09a697ee95302a3ef2dd43fd6eb709e570" }, + "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, + "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, + "nvim-lspconfig": { "branch": "master", "commit": "3371bf298c1f56efc26771ee961f461176958fb5" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" }, + "nvim-surround": { "branch": "main", "commit": "8b47db616ef658b8fc27e61db2896aa2f40134de" }, + "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, + "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, + "onedark.nvim": { "branch": "master", "commit": "df4792accde9db0043121f32628bcf8e645d9aea" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "render-markdown.nvim": { "branch": "main", "commit": "f422cb5c6855f150e2ddcfaf44e7157b98b34f6a" }, + "smear-cursor.nvim": { "branch": "main", "commit": "9e9378d6ee34bb3782e0e8c63d9ec8ca618b479b" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, + "telescope-live-grep-args.nvim": { "branch": "master", "commit": "53e9df55b3651dd7cf77e172f1e8c9a17407acca" }, + "telescope-luasnip.nvim": { "branch": "master", "commit": "07a2a2936a7557404c782dba021ac0a03165b343" }, + "telescope.nvim": { "branch": "master", "commit": "427b576c16792edad01a92b89721d923c19ad60f" }, + "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, + "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, + "treesitter-modules.nvim": { "branch": "main", "commit": "290eec96bfc43ed28264661dd30e894a60c4b99c" }, + "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, + "vim-floaterm": { "branch": "master", "commit": "bb4ba7952e906408e1f83b215f55ffe57efcade6" }, + "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, + "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } +} diff --git a/lua/bootstrap/pacman.lua b/lua/bootstrap/pacman.lua deleted file mode 100644 index 2dbbf12390e..00000000000 --- a/lua/bootstrap/pacman.lua +++ /dev/null @@ -1,111 +0,0 @@ --- ~/.config/nvim/lua/bootstrap/pacman.lua --- Fix1: run pacman inside a Neovim terminal so sudo has a real TTY. - -local M = {} - -local function has_exe(exe) - return vim.fn.executable(exe) == 1 -end - -local function pacman_has(pkg) - local out = vim.fn.system({ "pacman", "-Qi", pkg }) - return vim.v.shell_error == 0 and out ~= nil and out ~= "" -end - -local function missing_pkgs(pkgs) - local missing = {} - for _, p in ipairs(pkgs) do - if not pacman_has(p) then - table.insert(missing, p) - end - end - return missing -end - -local function shell_escape_arg(s) - -- minimal quoting for a shell command string - return "'" .. tostring(s):gsub("'", [['"'"']]) .. "'" -end - -local function open_install_terminal(pkgs) - if #pkgs == 0 then - return true - end - - if not has_exe("sudo") then - vim.notify("Missing `sudo`; cannot auto-install pacman deps.", vim.log.levels.ERROR) - return false - end - - -- Build a single shell command so sudo prompts normally. - local parts = { "sudo", "pacman", "-S", "--needed" } - for _, p in ipairs(pkgs) do - table.insert(parts, shell_escape_arg(p)) - end - local cmd = table.concat(parts, " ") - - vim.notify("Opening terminal to install:\n" .. table.concat(pkgs, ", "), vim.log.levels.WARN) - - -- Open a terminal split and run the command. User can enter sudo password normally. - vim.cmd("botright 15split") - vim.cmd("terminal " .. cmd) - vim.cmd("startinsert") - - return true -end - -function M.check() - if not has_exe("pacman") then - vim.notify("pacman not found. This bootstrap is Arch-specific.", vim.log.levels.WARN) - return {} - end - local deps = require("bootstrap.deps") - return missing_pkgs(deps) -end - -function M.install(opts) - opts = opts or {} - local miss = M.check() - if #miss == 0 then - if not opts.quiet then - vim.notify("All system deps already installed.", vim.log.levels.INFO) - end - return true - end - - local prompt = "Missing system deps:\n\n" - .. table.concat(miss, "\n") - .. "\n\nOpen a terminal and run sudo pacman to install them?" - - local ok = true - if not opts.force then - ok = (vim.fn.confirm(prompt, "&Yes\n&No", 1) == 1) - end - if not ok then - return false - end - - return open_install_terminal(miss) -end - --- Commands -vim.api.nvim_create_user_command("DepsCheck", function() - local miss = M.check() - if #miss == 0 then - vim.notify("DepsCheck: OK (no missing packages).", vim.log.levels.INFO) - else - vim.notify("DepsCheck missing:\n" .. table.concat(miss, ", "), vim.log.levels.WARN) - end -end, {}) - -vim.api.nvim_create_user_command("DepsInstall", function() - M.install({ force = true }) -end, {}) - --- Run once per session (prompt-based) -if vim.g.__deps_bootstrap_ran ~= true then - vim.g.__deps_bootstrap_ran = true - M.install({ force = false, quiet = true }) -end - -return M diff --git a/scripts/nvim-test.sh b/scripts/nvim-test.sh new file mode 100755 index 00000000000..7f7b95dc629 --- /dev/null +++ b/scripts/nvim-test.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail + +mode="${1:-restore}" +if [[ "$mode" != "restore" && "$mode" != "update" ]]; then + echo "usage: $0 [restore|update]" >&2 + exit 2 +fi + +root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +nvim="${NVIM_BIN:-nvim}" +tmp="$(mktemp -d)" +trap 'rm -rf "$tmp"' EXIT + +mkdir -p "$tmp/config" +ln -s "$root" "$tmp/config/nvim" + +export XDG_CONFIG_HOME="$tmp/config" +export XDG_DATA_HOME="$tmp/data" +export XDG_STATE_HOME="$tmp/state" +export XDG_CACHE_HOME="$tmp/cache" +export NVIM_SKIP_TOOL_INSTALL=1 + +"$nvim" --headless "+Lazy! $mode" +qa +"$nvim" --headless \ + "+Lazy load all" \ + "+lua assert(vim.fn.exists(':Lazy') == 2, 'lazy.nvim did not load')" \ + "+lua if vim.v.errmsg ~= '' then print(vim.v.errmsg); vim.cmd('cquit 1') end" \ + +qa + +"$nvim" --headless \ + "+checkhealth vim.deprecated" \ + "+silent write! $tmp/deprecated.txt" \ + +qa + +if grep -q 'WARNING\|ERROR' "$tmp/deprecated.txt"; then + cat "$tmp/deprecated.txt" + exit 1 +fi