Compare commits
71 Commits
b9f1478645
...
8eb5b3b325
Author | SHA1 | Date |
---|---|---|
Julian Raufelder | 8eb5b3b325 | |
Julian Raufelder | ca3c4010c2 | |
John Pekcan | 4d0dc8d4b1 | |
Ari Pollak | e39a8bce9d | |
Shashwat Agrawal | 76c5b1ec57 | |
Damjan 9000 | 3824342d10 | |
Damjan 9000 | f8c8b08bc1 | |
Damjan 9000 | 12bd68e8b9 | |
Damjan 9000 | 3ca08acf0e | |
Sudo | 39ae0829ac | |
Damjan 9000 | afafc9ab19 | |
matt | 14cf319dbd | |
Tommy Williams | ee9790b381 | |
Chris Patti | 1915cea32e | |
j-hui | 711e5976dd | |
Chris Patti | fa94716dce | |
Shashwat Agrawal | af4f51b2cd | |
Chris Patti | a005f15cec | |
Damjan 9000 | c8dd8e7e0c | |
Damjan 9000 | f23484cf88 | |
Chris Patti | 47974f7db1 | |
Sebastian Lara Menares | 1d14453024 | |
Chris Patti | bced1c2943 | |
Chris Patti | 1c59dc28c8 | |
Sebastian Lara Menares | 5ce4f38e1e | |
Sebastian Lara Menares | 0fda9af7c9 | |
Chris Patti | 29c77cd7e5 | |
Damjan 9000 | 1ad1ec2509 | |
n-a11s | 4d2cf48fb6 | |
Chris Patti | 99acb843ac | |
Damjan 9000 | 0dd934ee01 | |
Chris Patti | a3f3e08f34 | |
Damjan 9000 | 68b1981f02 | |
Julian Raufelder | f0cc2f931e | |
Julian Raufelder | 8171e1dd91 | |
Chris Patti | 9b256d9368 | |
Theo P | 5d8921990b | |
Chris Patti | 0b659bd508 | |
Julian Raufelder | c53c42350d | |
Julian Raufelder | b09370df83 | |
Julian Raufelder | 235b9c5f49 | |
Julian Raufelder | 9682dda165 | |
Julian Raufelder | 4230158ff5 | |
Julian Raufelder | c705d03a4b | |
Julian Raufelder | d77d805495 | |
Julian Raufelder | a64cddd5c8 | |
Alvaro-Kothe | db7189f35c | |
Chris Patti | 58f2dbab70 | |
Chris Patti | 9fe8b20f03 | |
Pedro Santayana | c27b05467a | |
Ashraf Michail | 01ed2525bb | |
Chris Patti | 53e925240f | |
Chris Patti | f70edeec1b | |
Anthony Fiddes | 36224daa1b | |
amtoine | 21b175d21b | |
Anthony Fiddes | 6ffc5a169f | |
Chris Patti | f15af9b8be | |
Chris Patti | 313bd75ca0 | |
Ashraf Michail | 4d5f24d6c1 | |
Chris Patti | daf2dc38fc | |
Chris Patti | fca29aa644 | |
Lukas Reineke | 7a58588a92 | |
Chris Patti | e8c70473c9 | |
Emmanuel Chucks | 878ec12318 | |
Chris Patti | 3668af39f4 | |
Anthony Fiddes | aff064f714 | |
tcld | 0340f77200 | |
Chris Patti | d891f4ac5a | |
Christopher Gillis | 8443853cfe | |
Chris Patti | 4b31f8ef9e | |
Luca Saccarola | 24885f2483 |
|
@ -0,0 +1,18 @@
|
|||
# Check Lua Formatting
|
||||
name: Check Lua Formatting
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
stylua-check:
|
||||
name: Stylua Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
- name: Stylua Check
|
||||
uses: JohnnyMorganz/stylua-action@v3
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
version: latest
|
||||
args: --check .
|
||||
|
|
@ -2,4 +2,3 @@ tags
|
|||
test.sh
|
||||
.luarc.json
|
||||
nvim
|
||||
lazy-lock.json
|
||||
|
|
63
README.md
63
README.md
|
@ -20,7 +20,7 @@ Distribution Alternatives:
|
|||
|
||||
### Installation
|
||||
|
||||
> **NOTE**
|
||||
> **NOTE**
|
||||
> [Backup](#FAQ) your previous configuration (if any exists)
|
||||
|
||||
Requirements:
|
||||
|
@ -32,35 +32,46 @@ Neovim's configurations are located under the following paths, depending on your
|
|||
|
||||
| OS | PATH |
|
||||
| :- | :--- |
|
||||
| Linux | `~/.config/nvim` |
|
||||
| MacOS | `~/.config/nvim` |
|
||||
| Windows | `%userprofile%\AppData\Local\nvim\` |
|
||||
| Linux | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` |
|
||||
| MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` |
|
||||
| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` |
|
||||
| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` |
|
||||
|
||||
#### Archive Installation
|
||||
|
||||
* On the home/landing page for the project find the green "`<> CODE`" button click it and select `Local > Download ZIP`.
|
||||
* Extract the archive to the appropriate configuration path.
|
||||
* 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
|
||||
|
||||
From a terminal `cd`/`dir` to the configuration path and then run:
|
||||
Clone kickstart.nvim:
|
||||
|
||||
- on Linux and Mac
|
||||
```sh
|
||||
git clone https://github.com/nvim-lua/kickstart.nvim.git ~/.config/nvim
|
||||
# OR
|
||||
gh repo clone nvim-lua/kickstart.nvim
|
||||
git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
|
||||
```
|
||||
|
||||
- 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
|
||||
|
||||
Run the following command and then **you are ready to go**!
|
||||
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 Optional
|
||||
### 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.
|
||||
|
||||
|
@ -144,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.
|
||||
* 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)
|
||||
* 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
|
||||
* Are there any cool videos about this plugin?
|
||||
* 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.
|
||||
* 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
|
||||
|
||||
|
|
433
init.lua
433
init.lua
|
@ -37,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 :)
|
||||
--]]
|
||||
|
||||
-- Set <space> 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
|
||||
-- [[ Install `lazy.nvim` plugin manager ]]
|
||||
-- https://github.com/folke/lazy.nvim
|
||||
-- `:help lazy.nvim.txt` for more info
|
||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
|
@ -59,6 +60,7 @@ if not vim.loop.fs_stat(lazypath) then
|
|||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- [[ Configure plugins ]]
|
||||
-- NOTE: Here is where you install your plugins.
|
||||
-- You can configure plugins using the `config` key.
|
||||
--
|
||||
|
@ -86,7 +88,7 @@ require('lazy').setup({
|
|||
|
||||
-- Useful status updates for LSP
|
||||
-- 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!
|
||||
'folke/neodev.nvim',
|
||||
|
@ -103,6 +105,7 @@ require('lazy').setup({
|
|||
|
||||
-- Adds LSP completion capabilities
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-path',
|
||||
|
||||
-- Adds a number of user-friendly snippets
|
||||
'rafamadriz/friendly-snippets',
|
||||
|
@ -125,19 +128,69 @@ require('lazy').setup({
|
|||
},
|
||||
on_attach = function(bufnr)
|
||||
vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' })
|
||||
vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk, { buffer = bufnr, desc = '[G]o to [P]revious 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)
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map({ '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)
|
||||
end, { expr = true, desc = 'Jump to next hunk' })
|
||||
|
||||
map({ '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, { expr = true, desc = 'Jump to previous hunk' })
|
||||
|
||||
-- Actions
|
||||
-- visual mode
|
||||
map('v', '<leader>hs', function()
|
||||
gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
|
||||
end, { desc = 'stage git hunk' })
|
||||
map('v', '<leader>hr', function()
|
||||
gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
|
||||
end, { desc = 'reset git hunk' })
|
||||
-- normal mode
|
||||
map('n', '<leader>hs', gs.stage_hunk, { desc = 'git stage hunk' })
|
||||
map('n', '<leader>hr', gs.reset_hunk, { desc = 'git reset hunk' })
|
||||
map('n', '<leader>hS', gs.stage_buffer, { desc = 'git Stage buffer' })
|
||||
map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' })
|
||||
map('n', '<leader>hR', gs.reset_buffer, { desc = 'git Reset buffer' })
|
||||
map('n', '<leader>hp', gs.preview_hunk, { desc = 'preview git hunk' })
|
||||
map('n', '<leader>hb', function()
|
||||
gs.blame_line { full = false }
|
||||
end, { desc = 'git blame line' })
|
||||
map('n', '<leader>hd', gs.diffthis, { desc = 'git diff against index' })
|
||||
map('n', '<leader>hD', function()
|
||||
gs.diffthis '~'
|
||||
end, { desc = 'git diff against last commit' })
|
||||
|
||||
-- Toggles
|
||||
map('n', '<leader>tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' })
|
||||
map('n', '<leader>td', gs.toggle_deleted, { desc = 'toggle git show deleted' })
|
||||
|
||||
-- Text object
|
||||
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
@ -169,11 +222,9 @@ require('lazy').setup({
|
|||
-- Add indentation guides even on blank lines
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
-- Enable `lukas-reineke/indent-blankline.nvim`
|
||||
-- See `:help indent_blankline.txt`
|
||||
opts = {
|
||||
char = '┊',
|
||||
show_trailing_blankline_indent = false,
|
||||
},
|
||||
-- See `:help ibl`
|
||||
main = 'ibl',
|
||||
opts = {},
|
||||
},
|
||||
|
||||
-- "gc" to comment visual regions/lines
|
||||
|
@ -209,7 +260,56 @@ require('lazy').setup({
|
|||
build = ':TSUpdate',
|
||||
},
|
||||
|
||||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
||||
{'gelguy/wilder.nvim', version = "*", config = function() end },
|
||||
-- File browser
|
||||
{
|
||||
"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,
|
||||
},
|
||||
-- Markdown preview
|
||||
{'iamcco/markdown-preview.nvim',
|
||||
ft = "markdown",
|
||||
-- build = "cd app && yarn install", -- after removing Joplin one day
|
||||
build = "cd app && npm install",
|
||||
init = function() vim.g.mkdp_filetypes = { "markdown" } end,
|
||||
},
|
||||
-- show notifications etc in a nice area
|
||||
{'folke/noice.nvim',
|
||||
event = 'VeryLazy',
|
||||
opts = {
|
||||
},
|
||||
dependencies = {
|
||||
'MunifTanjim/nui.nvim',
|
||||
'rcarriga/nvim-notify',
|
||||
}
|
||||
},
|
||||
-- tmux vim keybindings
|
||||
'christoomey/vim-tmux-navigator',
|
||||
-- databse connections from within vim using DBGUI and DB
|
||||
'tpope/vim-dadbod',
|
||||
'kristijanhusak/vim-dadbod-ui',
|
||||
'kristijanhusak/vim-dadbod-completion',
|
||||
{
|
||||
-- Highlight, edit, and navigate code
|
||||
'ThePrimeagen/harpoon',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
},
|
||||
},
|
||||
'mbbill/undotree',
|
||||
'tpope/vim-surround',
|
||||
'tpope/vim-commentary',
|
||||
'github/copilot.vim',
|
||||
|
||||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
||||
-- These are some example plugins that I've included in the kickstart repository.
|
||||
-- Uncomment any of the lines below to enable them.
|
||||
-- require 'kickstart.plugins.autoformat',
|
||||
|
@ -234,14 +334,33 @@ vim.o.hlsearch = false
|
|||
-- Make line numbers default
|
||||
vim.wo.number = true
|
||||
|
||||
-- Toggle line numbers depending on the vim mode
|
||||
local augroup = vim.api.nvim_create_augroup("numbertoggle", {})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "CmdlineLeave", "WinEnter" }, {
|
||||
pattern = "*",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
if vim.o.nu and vim.api.nvim_get_mode().mode ~= "i" then
|
||||
vim.opt.relativenumber = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "CmdlineEnter", "WinLeave" }, {
|
||||
pattern = "*",
|
||||
group = augroup,
|
||||
callback = function()
|
||||
if vim.o.nu then
|
||||
vim.opt.relativenumber = false
|
||||
vim.cmd "redraw"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Enable mouse mode
|
||||
vim.o.mouse = 'a'
|
||||
|
||||
-- Sync clipboard between OS and Neovim.
|
||||
-- Remove this option if you want your OS clipboard to remain independent.
|
||||
-- See `:help 'clipboard'`
|
||||
vim.o.clipboard = 'unnamedplus'
|
||||
|
||||
-- Enable break indent
|
||||
vim.o.breakindent = true
|
||||
|
||||
|
@ -275,6 +394,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', '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 ]]
|
||||
-- See `:help vim.highlight.on_yank()`
|
||||
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
||||
|
@ -297,11 +422,54 @@ require('telescope').setup {
|
|||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
live_grep = {
|
||||
additional_args = function(opts)
|
||||
return {"--hidden"}
|
||||
end
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Enable telescope fzf native, if installed
|
||||
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`
|
||||
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' })
|
||||
|
@ -313,85 +481,92 @@ vim.keymap.set('n', '<leader>/', function()
|
|||
})
|
||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||
|
||||
local function telescope_live_grep_open_files()
|
||||
require('telescope.builtin').live_grep {
|
||||
grep_open_files = true,
|
||||
prompt_title = 'Live Grep in Open Files',
|
||||
}
|
||||
end
|
||||
vim.keymap.set('n', '<leader>s/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' })
|
||||
vim.keymap.set('n', '<leader>ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' })
|
||||
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
|
||||
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>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>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]resume' })
|
||||
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
|
||||
vim.keymap.set('n', '<leader>sfn', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles [N]o Hidden' })
|
||||
vim.keymap.set('n', '<leader>sfh', '<Cmd>Telescope find_files hidden=true no_ignore=true<Cr>', { desc = '[S]earch [F]iles [H]idden' })
|
||||
|
||||
-- [[ Configure Treesitter ]]
|
||||
-- See `:help nvim-treesitter`
|
||||
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' },
|
||||
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
|
||||
vim.defer_fn(function()
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- Add languages to be installed here that you want installed for treesitter
|
||||
ensure_installed = { 'lua', 'python', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash', 'css', 'dockerfile', 'html', 'java', 'kotlin', 'json', 'markdown_inline', 'ruby', 'sql', 'toml', 'vue', 'yaml' },
|
||||
|
||||
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
||||
auto_install = false,
|
||||
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
||||
auto_install = false,
|
||||
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = '<c-space>',
|
||||
node_incremental = '<c-space>',
|
||||
scope_incremental = '<c-s>',
|
||||
node_decremental = '<M-space>',
|
||||
},
|
||||
},
|
||||
textobjects = {
|
||||
select = {
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
incremental_selection = {
|
||||
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',
|
||||
init_selection = '<c-space>',
|
||||
node_incremental = '<c-space>',
|
||||
scope_incremental = '<c-s>',
|
||||
node_decremental = '<M-space>',
|
||||
},
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true, -- whether to set jumps in the jumplist
|
||||
goto_next_start = {
|
||||
[']m'] = '@function.outer',
|
||||
[']]'] = '@class.outer',
|
||||
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',
|
||||
},
|
||||
},
|
||||
goto_next_end = {
|
||||
[']M'] = '@function.outer',
|
||||
[']['] = '@class.outer',
|
||||
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',
|
||||
},
|
||||
},
|
||||
goto_previous_start = {
|
||||
['[m'] = '@function.outer',
|
||||
['[['] = '@class.outer',
|
||||
},
|
||||
goto_previous_end = {
|
||||
['[M'] = '@function.outer',
|
||||
['[]'] = '@class.outer',
|
||||
swap = {
|
||||
enable = true,
|
||||
swap_next = {
|
||||
['<leader>a'] = '@parameter.inner',
|
||||
},
|
||||
swap_previous = {
|
||||
['<leader>A'] = '@parameter.inner',
|
||||
},
|
||||
},
|
||||
},
|
||||
swap = {
|
||||
enable = true,
|
||||
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' })
|
||||
}
|
||||
end, 0)
|
||||
|
||||
-- [[ Configure LSP ]]
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
|
@ -413,10 +588,10 @@ local on_attach = function(_, bufnr)
|
|||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
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('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>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
|
@ -438,6 +613,29 @@ local on_attach = function(_, bufnr)
|
|||
end, { desc = 'Format current buffer with LSP' })
|
||||
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 = 'Git [H]unk', _ = 'which_key_ignore' },
|
||||
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
||||
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
||||
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
|
||||
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
||||
}
|
||||
-- register which-key VISUAL mode
|
||||
-- required for visual <leader>hs (hunk stage) to work
|
||||
require('which-key').register({
|
||||
['<leader>'] = { name = 'VISUAL <leader>' },
|
||||
['<leader>h'] = { 'Git [H]unk' },
|
||||
}, { mode = 'v' })
|
||||
|
||||
-- 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
|
||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||
--
|
||||
|
@ -458,6 +656,8 @@ local servers = {
|
|||
Lua = {
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
-- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings
|
||||
-- diagnostics = { disable = { 'missing-fields' } },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -484,7 +684,7 @@ mason_lspconfig.setup_handlers {
|
|||
settings = servers[server_name],
|
||||
filetypes = (servers[server_name] or {}).filetypes,
|
||||
}
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
-- [[ Configure nvim-cmp ]]
|
||||
|
@ -500,10 +700,13 @@ cmp.setup {
|
|||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
completion = {
|
||||
completeopt = 'menu,menuone,noinsert',
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete {},
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
|
@ -532,8 +735,66 @@ cmp.setup {
|
|||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'path' },
|
||||
},
|
||||
}
|
||||
|
||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||
-- vim: ts=2 sts=2 sw=2 et
|
||||
--
|
||||
|
||||
vim.keymap.set('i', 'jj', '<esc>', { desc = 'Closes insert mode' })
|
||||
vim.keymap.set('n', 'ec', ':', { desc = 'Execute command' })
|
||||
|
||||
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv", { desc = 'Move line down' })
|
||||
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv", { desc = 'Move line up' })
|
||||
|
||||
vim.keymap.set('x', '<leader>p', "\"_dP", { desc = '[P]aste with previous still in buffer' })
|
||||
|
||||
vim.keymap.set('n', '<leader>y', "\"+y", { desc = '[Y]ank to system clipboard' })
|
||||
vim.keymap.set('v', '<leader>y', "\"+y", { desc = '[Y]ank to system clipboard' })
|
||||
vim.keymap.set('n', '<leader>Y', "\"+Y", { desc = '[Y]ank to system clipboard' })
|
||||
|
||||
vim.keymap.set('n', '<leader>rr', [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], { desc = '[R]ename by [R]egex pattern' })
|
||||
|
||||
-- map capital b and e to end/start line, should be default?
|
||||
vim.keymap.set('n', 'B', '_', { desc = 'Jump to line [B]eginning' })
|
||||
vim.keymap.set('n', 'E', '$', { desc = 'Jump to line [E]nding' })
|
||||
|
||||
-- wilder
|
||||
local wilder = require('wilder')
|
||||
wilder.setup({modes = {':', '/', '?'}})
|
||||
|
||||
-- filetree
|
||||
-- Unless you are still migrating, remove the deprecated commands from v1.x
|
||||
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
|
||||
|
||||
-- neo_tree
|
||||
vim.keymap.set('n', '<leader>f', '<Cmd>Neotree toggle<Cr>', { desc = 'Toggle NeoTree' })
|
||||
|
||||
-- database
|
||||
vim.keymap.set('n', '<leader>nu', '<Cmd>DBUIToggle<Cr>', { desc = 'Toggle UI' })
|
||||
vim.keymap.set('n', '<leader>nf', '<Cmd>DBUIFindBuffer<Cr>', { desc = 'Find buffer' })
|
||||
vim.keymap.set('n', '<leader>nr', '<Cmd>DBUIRenameBuffer<Cr>', { desc = 'Rename buffer' })
|
||||
vim.keymap.set('n', '<leader>nq', '<Cmd>DBUILastQueryInfo<Cr>', { desc = 'Last query info' })
|
||||
|
||||
-- harpoon
|
||||
local mark = require('harpoon.mark')
|
||||
local ui = require('harpoon.ui')
|
||||
|
||||
vim.keymap.set('n', '<leader>hh', mark.add_file, { desc = 'Add file to harpoon'})
|
||||
vim.keymap.set('n', '<C-e>', ui.toggle_quick_menu, { desc = 'Toggle harpoon quick menu'})
|
||||
|
||||
-- vim.keymap.set('n', '<C-h>', function () ui.nav_file(1) end, { desc = 'Harpoon file 1'})
|
||||
vim.keymap.set('n', '<C-t>', function () ui.nav_file(2) end, { desc = 'Harpoon file 2'})
|
||||
vim.keymap.set('n', '<C-n>', function () ui.nav_file(3) end, { desc = 'Harpoon file 3'})
|
||||
vim.keymap.set('n', '<C-s>', function () ui.nav_file(4) end, { desc = 'Harpoon file 4'})
|
||||
|
||||
-- undotree
|
||||
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle , { desc = 'Toggle Undotree'})
|
||||
|
||||
-- copilot disabled by default, enable it by typing :let b:copilot_enabled = 1
|
||||
vim.g.copilot_assume_mapped = true
|
||||
vim.api.nvim_exec([[ au BufNewFile,BufRead * let b:copilot_enabled = 0 ]], false)
|
||||
vim.api.nvim_create_user_command('ThisIsYourCaptainSpeaking', 'let b:copilot_enabled = 1', {})
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
|
||||
"LuaSnip": { "branch": "master", "commit": "2463d687fe704b76eb0aa3bb34e95f69a5bb0362" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"copilot.vim": { "branch": "release", "commit": "5b19fb001d7f31c4c7c5556d7a97b243bd29f45f" },
|
||||
"fidget.nvim": { "branch": "main", "commit": "a4a7edfea37e557dbff5509ee374ffb57051bba9" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "53d3df271d031c405255e99410628c26a8f0d2b0" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" },
|
||||
"harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "5da5546947f3125dfd6aa85ab21074dc83f776d5" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" },
|
||||
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" },
|
||||
"mason.nvim": { "branch": "main", "commit": "a09da6ac634926a299dd439da08bdb547a8ca011" },
|
||||
"neo-tree.nvim": { "branch": "main", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "7cb4f7f29c6bf6f1d21a37f6dd6d12ba64266b09" },
|
||||
"noice.nvim": { "branch": "main", "commit": "92433164e2f7118d4122c7674c3834d9511722ba" },
|
||||
"nui.nvim": { "branch": "main", "commit": "80445d015d2b5f9af0d9e8bce63d303bc86eda8a" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "9bedcfed749755e43fc8bed46f85ce2044fe3b77" },
|
||||
"nvim-notify": { "branch": "master", "commit": "ebcdd8219e2a2cbc0a4bef68002f6867f1fde269" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "e49f1e8ef3e8450a8446cb1f2bbb53c919f60b6d" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "0e2d5bd4cbe75849a013901555d436a48c6680cb" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "808627b8d412b2a6b6fc6eed816fec3557198b01" },
|
||||
"onedark.nvim": { "branch": "master", "commit": "c5476a091b0f1b4e853db91c91ff941f848a1cdd" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
|
||||
"telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
|
||||
"undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" },
|
||||
"vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" },
|
||||
"vim-dadbod": { "branch": "master", "commit": "738cfc2ea6a1510fe23cba9006fef9291be70f7b" },
|
||||
"vim-dadbod-completion": { "branch": "master", "commit": "c920cb0ba3dff4b1b0ed373e1c0b3007dec696c2" },
|
||||
"vim-dadbod-ui": { "branch": "master", "commit": "9ddb0623e69d696b7a8355b93e3950a8dc6e00a0" },
|
||||
"vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" },
|
||||
"vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" },
|
||||
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
|
||||
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
|
||||
"vim-tmux-navigator": { "branch": "master", "commit": "38b1d0402c4600543281dc85b3f51884205674b6" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" },
|
||||
"wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
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,
|
||||
}
|
Loading…
Reference in New Issue