commit
da24b5cb00
|
@ -2,4 +2,3 @@ tags
|
||||||
test.sh
|
test.sh
|
||||||
.luarc.json
|
.luarc.json
|
||||||
nvim
|
nvim
|
||||||
lazy-lock.json
|
|
||||||
|
|
92
README.md
92
README.md
|
@ -20,35 +20,63 @@ Distribution Alternatives:
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
* Backup your previous configuration (if any exists)
|
> **NOTE**
|
||||||
|
> [Backup](#FAQ) your previous configuration (if any exists)
|
||||||
|
|
||||||
### Archive Installation
|
Requirements:
|
||||||
* On the home/landing page for the project find the blue "<> CODE" button click it and select Local > Download ZIP.
|
* Make sure to review the readmes of the plugins if you are experiencing errors. In particular:
|
||||||
* Extract the archive to:
|
* [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers.
|
||||||
`~/.config/nvim` (Linux)
|
* See [Windows Installation](#Windows-Installation) if you have trouble with `telescope-fzf-native`
|
||||||
`~/.config/nvim` (MacOS)
|
|
||||||
`%userprofile%\AppData\Local\nvim\` (Windows)
|
|
||||||
* Ensure your extraction method did not extract with a parent folder. For example in ~/.config/nvim you should have init.lua not another folder called kickstart.nvim.
|
|
||||||
|
|
||||||
### Git Clone Installation
|
Neovim's configurations are located under the following paths, depending on your OS:
|
||||||
* From a terminal cd/dir to:
|
|
||||||
`~/.config/nvim` (Linux)
|
|
||||||
`~/.config/nvim` (MacOS)
|
|
||||||
`%userprofile%\AppData\Local\nvim\` (Windows)
|
|
||||||
|
|
||||||
* run: `git clone https://github.com/nvim-lua/kickstart.nvim.git ~/.config/nvim` OR: `gh repo clone nvim-lua/kickstart.nvim`
|
| OS | PATH |
|
||||||
* Run Neovim (from terminal or shortcut) and allow lazy.nvim to download files and set up the basics.
|
| :- | :--- |
|
||||||
* Once the setup is complete, restart Neovim.
|
| Linux | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` |
|
||||||
* **You're ready to go!**
|
| MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` |
|
||||||
|
| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` |
|
||||||
|
| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` |
|
||||||
|
|
||||||
* (Recommended/Optional) Fork this repo (so that you have your own copy that you can modify).
|
Clone kickstart.nvim:
|
||||||
* Clone the kickstart repo into `$HOME/.config/nvim/` (Linux/Mac) or `%userprofile%\AppData\Local\nvim\` (Windows)
|
|
||||||
* If you don't want to include it as a git repo, you can just clone it and then move the files to this location
|
|
||||||
|
|
||||||
Additional system requirements:
|
- on Linux and Mac
|
||||||
- Make sure to review the readmes of the plugins if you are experiencing errors. In particular:
|
```sh
|
||||||
- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers.
|
git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
|
||||||
- See [Windows Installation](#Windows-Installation) if you have trouble with `telescope-fzf-native`
|
```
|
||||||
|
|
||||||
|
- on Windows (cmd)
|
||||||
|
```
|
||||||
|
git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\
|
||||||
|
```
|
||||||
|
|
||||||
|
- on Windows (powershell)
|
||||||
|
```
|
||||||
|
git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Post Installation
|
||||||
|
|
||||||
|
Start Neovim
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nvim
|
||||||
|
```
|
||||||
|
|
||||||
|
The `Lazy` plugin manager will start automatically on the first run and install the configured plugins - as can be seen in the introduction video. After the installation is complete you can press `q` to close the `Lazy` UI and **you are ready to go**! Next time you run nvim `Lazy` will no longer show up.
|
||||||
|
|
||||||
|
If you would prefer to hide this step and run the plugin sync from the command line, you can use:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nvim --headless "+Lazy! sync" +qa
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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/<your_github_username>/kickstart.nvim.git`
|
||||||
|
|
||||||
### Configuration And Extension
|
### Configuration And Extension
|
||||||
|
|
||||||
|
@ -127,11 +155,27 @@ Each PR, especially those which increase the line count, should have a descripti
|
||||||
* You should back it up, then delete all files associated with it.
|
* 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/`
|
* This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/`
|
||||||
* You may also want to look at the [migration guide for lazy.nvim](https://github.com/folke/lazy.nvim#-migration-guide)
|
* You may also want to look at the [migration guide for lazy.nvim](https://github.com/folke/lazy.nvim#-migration-guide)
|
||||||
|
* 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:
|
* What if I want to "uninstall" this configuration:
|
||||||
* See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information
|
* See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information
|
||||||
* Are there any cool videos about this plugin?
|
* Are there any cool videos about this plugin?
|
||||||
* Current iteration of kickstart (coming soon)
|
* Current iteration of kickstart (coming soon)
|
||||||
* Here is one about the previous iteration of kickstart: [video introduction to Kickstart.nvim](https://youtu.be/stqUbv-5u2s). Note the install via init.lua no longer works as specified. Please follow the install instructions in this file instead as they're up to date.
|
* Here is one about the previous iteration of kickstart: [video introduction to Kickstart.nvim](https://youtu.be/stqUbv-5u2s). Note the install via init.lua no longer works as specified. Please follow the install instructions in this file instead as they're up to date.
|
||||||
|
* 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
|
### Windows Installation
|
||||||
|
|
||||||
|
|
231
init.lua
231
init.lua
|
@ -17,7 +17,9 @@ Kickstart.nvim is a template for your own configuration.
|
||||||
a guide. One possible example:
|
a guide. One possible example:
|
||||||
- https://learnxinyminutes.com/docs/lua/
|
- https://learnxinyminutes.com/docs/lua/
|
||||||
|
|
||||||
|
|
||||||
And then you can explore or search through `:help lua-guide`
|
And then you can explore or search through `:help lua-guide`
|
||||||
|
- https://neovim.io/doc/user/lua-guide.html
|
||||||
|
|
||||||
|
|
||||||
Kickstart Guide:
|
Kickstart Guide:
|
||||||
|
@ -35,13 +37,14 @@ I hope you enjoy your Neovim journey,
|
||||||
|
|
||||||
P.S. You can delete this when you're done too. It's your config now :)
|
P.S. You can delete this when you're done too. It's your config now :)
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
-- Set <space> as the leader key
|
-- Set <space> as the leader key
|
||||||
-- See `:help mapleader`
|
-- See `:help mapleader`
|
||||||
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
-- Install package manager
|
-- [[ Install `lazy.nvim` plugin manager ]]
|
||||||
-- https://github.com/folke/lazy.nvim
|
-- https://github.com/folke/lazy.nvim
|
||||||
-- `:help lazy.nvim.txt` for more info
|
-- `:help lazy.nvim.txt` for more info
|
||||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||||
|
@ -57,6 +60,7 @@ if not vim.loop.fs_stat(lazypath) then
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
-- [[ Configure plugins ]]
|
||||||
-- NOTE: Here is where you install your plugins.
|
-- NOTE: Here is where you install your plugins.
|
||||||
-- You can configure plugins using the `config` key.
|
-- You can configure plugins using the `config` key.
|
||||||
--
|
--
|
||||||
|
@ -79,12 +83,12 @@ require('lazy').setup({
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Automatically install LSPs to stdpath for neovim
|
-- Automatically install LSPs to stdpath for neovim
|
||||||
{ 'williamboman/mason.nvim', config = true },
|
'williamboman/mason.nvim',
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'williamboman/mason-lspconfig.nvim',
|
||||||
|
|
||||||
-- Useful status updates for LSP
|
-- Useful status updates for LSP
|
||||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||||
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
|
{ 'j-hui/fidget.nvim', opts = {} },
|
||||||
|
|
||||||
-- Additional lua configuration, makes nvim stuff amazing!
|
-- Additional lua configuration, makes nvim stuff amazing!
|
||||||
'folke/neodev.nvim',
|
'folke/neodev.nvim',
|
||||||
|
@ -122,9 +126,28 @@ require('lazy').setup({
|
||||||
changedelete = { text = '~' },
|
changedelete = { text = '~' },
|
||||||
},
|
},
|
||||||
on_attach = function(bufnr)
|
on_attach = function(bufnr)
|
||||||
vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk, { buffer = bufnr, desc = '[G]o to [P]revious Hunk' })
|
vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' })
|
||||||
vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' })
|
|
||||||
vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' })
|
-- don't override the built-in and fugitive keymaps
|
||||||
|
local gs = package.loaded.gitsigns
|
||||||
|
vim.keymap.set({ 'n', 'v' }, ']c', function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return ']c'
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
gs.next_hunk()
|
||||||
|
end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, { expr = true, buffer = bufnr, desc = 'Jump to next hunk' })
|
||||||
|
vim.keymap.set({ 'n', 'v' }, '[c', function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return '[c'
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
gs.prev_hunk()
|
||||||
|
end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, { expr = true, buffer = bufnr, desc = 'Jump to previous hunk' })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -154,11 +177,9 @@ require('lazy').setup({
|
||||||
-- Add indentation guides even on blank lines
|
-- Add indentation guides even on blank lines
|
||||||
'lukas-reineke/indent-blankline.nvim',
|
'lukas-reineke/indent-blankline.nvim',
|
||||||
-- Enable `lukas-reineke/indent-blankline.nvim`
|
-- Enable `lukas-reineke/indent-blankline.nvim`
|
||||||
-- See `:help indent_blankline.txt`
|
-- See `:help ibl`
|
||||||
opts = {
|
main = 'ibl',
|
||||||
char = '┊',
|
opts = {},
|
||||||
show_trailing_blankline_indent = false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- "gc" to comment visual regions/lines
|
-- "gc" to comment visual regions/lines
|
||||||
|
@ -267,6 +288,12 @@ vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
||||||
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
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 })
|
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||||
|
|
||||||
|
-- Diagnostic keymaps
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
||||||
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
||||||
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
||||||
|
|
||||||
-- [[ Highlight on yank ]]
|
-- [[ Highlight on yank ]]
|
||||||
-- See `:help vim.highlight.on_yank()`
|
-- See `:help vim.highlight.on_yank()`
|
||||||
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
||||||
|
@ -294,6 +321,42 @@ require('telescope').setup {
|
||||||
-- Enable telescope fzf native, if installed
|
-- Enable telescope fzf native, if installed
|
||||||
pcall(require('telescope').load_extension, 'fzf')
|
pcall(require('telescope').load_extension, 'fzf')
|
||||||
|
|
||||||
|
-- Telescope live_grep in git root
|
||||||
|
-- Function to find the git root directory based on the current buffer's path
|
||||||
|
local function find_git_root()
|
||||||
|
-- Use the current buffer's path as the starting point for the git search
|
||||||
|
local current_file = vim.api.nvim_buf_get_name(0)
|
||||||
|
local current_dir
|
||||||
|
local cwd = vim.fn.getcwd()
|
||||||
|
-- If the buffer is not associated with a file, return nil
|
||||||
|
if current_file == "" then
|
||||||
|
current_dir = cwd
|
||||||
|
else
|
||||||
|
-- Extract the directory from the current file's path
|
||||||
|
current_dir = vim.fn.fnamemodify(current_file, ":h")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Find the Git root directory from the current file's path
|
||||||
|
local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")[1]
|
||||||
|
if vim.v.shell_error ~= 0 then
|
||||||
|
print("Not a git repository. Searching on current working directory")
|
||||||
|
return cwd
|
||||||
|
end
|
||||||
|
return git_root
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Custom live_grep function to search in git root
|
||||||
|
local function live_grep_git_root()
|
||||||
|
local git_root = find_git_root()
|
||||||
|
if git_root then
|
||||||
|
require('telescope.builtin').live_grep({
|
||||||
|
search_dirs = {git_root},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
|
||||||
|
|
||||||
-- See `:help telescope.builtin`
|
-- See `:help telescope.builtin`
|
||||||
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
|
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
|
||||||
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
|
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
|
||||||
|
@ -310,79 +373,78 @@ vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { des
|
||||||
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
||||||
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
||||||
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
|
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
|
||||||
|
vim.keymap.set('n', '<leader>sG', ':LiveGrepGitRoot<cr>', { desc = '[S]earch by [G]rep on Git Root' })
|
||||||
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||||
|
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
|
||||||
|
|
||||||
-- [[ Configure Treesitter ]]
|
-- [[ Configure Treesitter ]]
|
||||||
-- See `:help nvim-treesitter`
|
-- See `:help nvim-treesitter`
|
||||||
require('nvim-treesitter.configs').setup {
|
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
vim.defer_fn(function()
|
||||||
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' },
|
require('nvim-treesitter.configs').setup {
|
||||||
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
|
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' },
|
||||||
|
|
||||||
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
||||||
auto_install = false,
|
auto_install = false,
|
||||||
|
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
|
||||||
keymaps = {
|
|
||||||
init_selection = '<c-space>',
|
|
||||||
node_incremental = '<c-space>',
|
|
||||||
scope_incremental = '<c-s>',
|
|
||||||
node_decremental = '<M-space>',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
textobjects = {
|
|
||||||
select = {
|
|
||||||
enable = true,
|
enable = true,
|
||||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
|
||||||
keymaps = {
|
keymaps = {
|
||||||
-- You can use the capture groups defined in textobjects.scm
|
init_selection = '<c-space>',
|
||||||
['aa'] = '@parameter.outer',
|
node_incremental = '<c-space>',
|
||||||
['ia'] = '@parameter.inner',
|
scope_incremental = '<c-s>',
|
||||||
['af'] = '@function.outer',
|
node_decremental = '<M-space>',
|
||||||
['if'] = '@function.inner',
|
|
||||||
['ac'] = '@class.outer',
|
|
||||||
['ic'] = '@class.inner',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
move = {
|
textobjects = {
|
||||||
enable = true,
|
select = {
|
||||||
set_jumps = true, -- whether to set jumps in the jumplist
|
enable = true,
|
||||||
goto_next_start = {
|
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||||
[']m'] = '@function.outer',
|
keymaps = {
|
||||||
[']]'] = '@class.outer',
|
-- 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',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
goto_next_end = {
|
move = {
|
||||||
[']M'] = '@function.outer',
|
enable = true,
|
||||||
[']['] = '@class.outer',
|
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',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
goto_previous_start = {
|
swap = {
|
||||||
['[m'] = '@function.outer',
|
enable = true,
|
||||||
['[['] = '@class.outer',
|
swap_next = {
|
||||||
},
|
['<leader>a'] = '@parameter.inner',
|
||||||
goto_previous_end = {
|
},
|
||||||
['[M'] = '@function.outer',
|
swap_previous = {
|
||||||
['[]'] = '@class.outer',
|
['<leader>A'] = '@parameter.inner',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
swap = {
|
}
|
||||||
enable = true,
|
end, 0)
|
||||||
swap_next = {
|
|
||||||
['<leader>a'] = '@parameter.inner',
|
|
||||||
},
|
|
||||||
swap_previous = {
|
|
||||||
['<leader>A'] = '@parameter.inner',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Diagnostic keymaps
|
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
|
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
|
||||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
|
||||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
|
||||||
|
|
||||||
-- [[ Configure LSP ]]
|
-- [[ Configure LSP ]]
|
||||||
-- This function gets run when an LSP connects to a particular buffer.
|
-- This function gets run when an LSP connects to a particular buffer.
|
||||||
|
@ -404,10 +466,10 @@ local on_attach = function(_, bufnr)
|
||||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||||
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||||
|
|
||||||
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||||
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
|
||||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||||
|
|
||||||
|
@ -429,6 +491,22 @@ local on_attach = function(_, bufnr)
|
||||||
end, { desc = 'Format current buffer with LSP' })
|
end, { desc = 'Format current buffer with LSP' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- document existing key chains
|
||||||
|
require('which-key').register {
|
||||||
|
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
|
||||||
|
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
|
||||||
|
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
|
||||||
|
['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' },
|
||||||
|
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
||||||
|
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
||||||
|
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
||||||
|
}
|
||||||
|
|
||||||
|
-- mason-lspconfig requires that these setup functions are called in this order
|
||||||
|
-- before setting up the servers.
|
||||||
|
require('mason').setup()
|
||||||
|
require('mason-lspconfig').setup()
|
||||||
|
|
||||||
-- Enable the following language servers
|
-- Enable the following language servers
|
||||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||||
--
|
--
|
||||||
|
@ -449,6 +527,8 @@ local servers = {
|
||||||
Lua = {
|
Lua = {
|
||||||
workspace = { checkThirdParty = false },
|
workspace = { checkThirdParty = false },
|
||||||
telemetry = { enable = false },
|
telemetry = { enable = false },
|
||||||
|
-- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings
|
||||||
|
-- diagnostics = { disable = { 'missing-fields' } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -475,7 +555,7 @@ mason_lspconfig.setup_handlers {
|
||||||
settings = servers[server_name],
|
settings = servers[server_name],
|
||||||
filetypes = (servers[server_name] or {}).filetypes,
|
filetypes = (servers[server_name] or {}).filetypes,
|
||||||
}
|
}
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- [[ Configure nvim-cmp ]]
|
-- [[ Configure nvim-cmp ]]
|
||||||
|
@ -491,6 +571,9 @@ cmp.setup {
|
||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
completion = {
|
||||||
|
completeopt = 'menu,menuone,noinsert'
|
||||||
|
},
|
||||||
mapping = cmp.mapping.preset.insert {
|
mapping = cmp.mapping.preset.insert {
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
|
Loading…
Reference in New Issue