here we go again
This commit is contained in:
parent
f218a37879
commit
ab5a430ce9
517
init.lua
517
init.lua
|
@ -240,45 +240,12 @@ require('lazy').setup({
|
||||||
-- "gc" to comment visual regions/lines
|
-- "gc" to comment visual regions/lines
|
||||||
{ 'numToStr/Comment.nvim', opts = {} },
|
{ 'numToStr/Comment.nvim', opts = {} },
|
||||||
|
|
||||||
-- NOTE: This is where your plugins related to LSP can be installed.
|
-- Here is a more advanced example where we pass configuration
|
||||||
-- The configuration is done below. Search for lspconfig to find it below.
|
-- options to `gitsigns.nvim`. This is equivalent to the following Lua:
|
||||||
{
|
-- require('gitsigns').setup({ ... })
|
||||||
-- LSP Configuration & Plugins
|
|
||||||
'neovim/nvim-lspconfig',
|
|
||||||
dependencies = {
|
|
||||||
-- Automatically install LSPs to stdpath for neovim
|
|
||||||
{ 'williamboman/mason.nvim', config = true },
|
|
||||||
'williamboman/mason-lspconfig.nvim',
|
|
||||||
|
|
||||||
-- Useful status updates for LSP
|
|
||||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
|
||||||
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
|
|
||||||
|
|
||||||
-- Additional lua configuration, makes nvim stuff amazing!
|
|
||||||
'folke/neodev.nvim',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Autocompletion
|
|
||||||
'hrsh7th/nvim-cmp',
|
|
||||||
dependencies = {
|
|
||||||
-- Snippet Engine & its associated nvim-cmp source
|
|
||||||
'L3MON4D3/LuaSnip',
|
|
||||||
'saadparwaiz1/cmp_luasnip',
|
|
||||||
|
|
||||||
-- Adds LSP completion capabilities
|
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
|
||||||
|
|
||||||
-- Adds a number of user-friendly snippets
|
|
||||||
'rafamadriz/friendly-snippets',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
--
|
--
|
||||||
-- Useful plugin to show you pending keybinds.
|
-- See `:help gitsigns` to understand what the configuration keys do
|
||||||
{ 'folke/which-key.nvim', opts = {} },
|
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
|
||||||
{
|
|
||||||
-- Adds git releated signs to the gutter, as well as utilities for managing changes
|
|
||||||
'lewis6991/gitsigns.nvim',
|
'lewis6991/gitsigns.nvim',
|
||||||
opts = {
|
opts = {
|
||||||
signs = {
|
signs = {
|
||||||
|
@ -326,62 +293,20 @@ require('lazy').setup({
|
||||||
require('which-key').register({
|
require('which-key').register({
|
||||||
['<leader>h'] = { 'Git [H]unk' },
|
['<leader>h'] = { 'Git [H]unk' },
|
||||||
}, { mode = 'v' })
|
}, { mode = 'v' })
|
||||||
{
|
|
||||||
"folke/tokyonight.nvim",
|
|
||||||
lazy = false,
|
|
||||||
priority = 1000,
|
|
||||||
opts = {
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
vim.cmd.colorscheme 'tokyonight-night'
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
-- Theme inspired by Atom
|
|
||||||
-- {
|
|
||||||
-- 'navarasu/onedark.nvim',
|
|
||||||
-- priority = 1000,
|
|
||||||
-- config = function()
|
|
||||||
-- vim.cmd.colorscheme 'onedark'
|
|
||||||
-- end,
|
|
||||||
-- },
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Set lualine as statusline
|
|
||||||
'nvim-lualine/lualine.nvim',
|
|
||||||
-- See `:help lualine.txt`
|
|
||||||
opts = {
|
|
||||||
options = {
|
|
||||||
icons_enabled = true,
|
|
||||||
theme = 'tokyonight',
|
|
||||||
component_separators = '|',
|
|
||||||
section_separators = '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = {} },
|
|
||||||
|
|
||||||
-- "gc" to comment visual regions/lines
|
|
||||||
{ 'numToStr/Comment.nvim', opts = {} },
|
|
||||||
|
|
||||||
-- Fuzzy Finder (files, lsp, etc)
|
|
||||||
{ '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,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
-- NOTE: Plugins can specify dependencies.
|
||||||
-- Highlight, edit, and navigate code
|
--
|
||||||
'nvim-treesitter/nvim-treesitter',
|
-- 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 = {
|
dependencies = {
|
||||||
'nvim-lua/plenary.nvim',
|
'nvim-lua/plenary.nvim',
|
||||||
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
|
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
|
||||||
|
@ -424,15 +349,82 @@ require('lazy').setup({
|
||||||
|
|
||||||
-- [[ Configure Telescope ]]
|
-- [[ Configure Telescope ]]
|
||||||
-- See `:help telescope` and `:help telescope.setup()`
|
-- See `:help telescope` and `:help telescope.setup()`
|
||||||
|
|
||||||
|
local actions = require "telescope.actions"
|
||||||
|
|
||||||
require('telescope').setup {
|
require('telescope').setup {
|
||||||
-- You can put your default mappings / updates / etc. in here
|
-- You can put your default mappings / updates / etc. in here
|
||||||
-- All the info you're looking for is in `:help telescope.setup()`
|
-- All the info you're looking for is in `:help telescope.setup()`
|
||||||
--
|
--
|
||||||
-- defaults = {
|
defaults = {
|
||||||
-- mappings = {
|
-- mappings = {
|
||||||
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
|
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
|
||||||
-- },
|
-- },
|
||||||
-- },
|
mappings = {
|
||||||
|
i = {
|
||||||
|
["<C-n>"] = actions.cycle_history_next,
|
||||||
|
["<C-p>"] = actions.cycle_history_prev,
|
||||||
|
|
||||||
|
["<C-j>"] = actions.move_selection_next,
|
||||||
|
["<C-k>"] = actions.move_selection_previous,
|
||||||
|
|
||||||
|
["<C-c>"] = actions.close,
|
||||||
|
|
||||||
|
["<Down>"] = actions.move_selection_next,
|
||||||
|
["<Up>"] = actions.move_selection_previous,
|
||||||
|
|
||||||
|
["<CR>"] = actions.select_default,
|
||||||
|
["<C-x>"] = actions.select_horizontal,
|
||||||
|
["<C-v>"] = actions.select_vertical,
|
||||||
|
["<C-t>"] = actions.select_tab,
|
||||||
|
|
||||||
|
["<C-u>"] = actions.preview_scrolling_up,
|
||||||
|
["<C-d>"] = actions.preview_scrolling_down,
|
||||||
|
|
||||||
|
["<PageUp>"] = actions.results_scrolling_up,
|
||||||
|
["<PageDown>"] = actions.results_scrolling_down,
|
||||||
|
|
||||||
|
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
||||||
|
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
||||||
|
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
||||||
|
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||||
|
["<C-l>"] = actions.complete_tag,
|
||||||
|
["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
|
||||||
|
},
|
||||||
|
|
||||||
|
n = {
|
||||||
|
["<esc>"] = actions.close,
|
||||||
|
["<CR>"] = actions.select_default,
|
||||||
|
["<C-x>"] = actions.select_horizontal,
|
||||||
|
["<C-v>"] = actions.select_vertical,
|
||||||
|
["<C-t>"] = actions.select_tab,
|
||||||
|
|
||||||
|
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
||||||
|
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
||||||
|
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
||||||
|
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||||
|
|
||||||
|
["j"] = actions.move_selection_next,
|
||||||
|
["k"] = actions.move_selection_previous,
|
||||||
|
["H"] = actions.move_to_top,
|
||||||
|
["M"] = actions.move_to_middle,
|
||||||
|
["L"] = actions.move_to_bottom,
|
||||||
|
|
||||||
|
["<Down>"] = actions.move_selection_next,
|
||||||
|
["<Up>"] = actions.move_selection_previous,
|
||||||
|
["gg"] = actions.move_to_top,
|
||||||
|
["G"] = actions.move_to_bottom,
|
||||||
|
|
||||||
|
["<C-u>"] = actions.preview_scrolling_up,
|
||||||
|
["<C-d>"] = actions.preview_scrolling_down,
|
||||||
|
|
||||||
|
["<PageUp>"] = actions.results_scrolling_up,
|
||||||
|
["<PageDown>"] = actions.results_scrolling_down,
|
||||||
|
|
||||||
|
["?"] = actions.which_key,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
-- pickers = {}
|
-- pickers = {}
|
||||||
extensions = {
|
extensions = {
|
||||||
['ui-select'] = {
|
['ui-select'] = {
|
||||||
|
@ -476,341 +468,10 @@ require('lazy').setup({
|
||||||
}
|
}
|
||||||
end, { desc = '[S]earch [/] in Open Files' })
|
end, { desc = '[S]earch [/] in Open Files' })
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
-- Shortcut for searching your Neovim configuration files
|
-- Shortcut for searching your Neovim configuration files
|
||||||
vim.keymap.set('n', '<leader>sn', function()
|
vim.keymap.set('n', '<leader>sn', function()
|
||||||
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
||||||
end, { desc = '[S]earch [N]eovim files' })
|
end, { desc = '[S]earch [N]eovim files' })
|
||||||
=======
|
|
||||||
-- 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
|
|
||||||
|
|
||||||
-- Save undo history
|
|
||||||
vim.o.undofile = true
|
|
||||||
|
|
||||||
-- Case-insensitive searching UNLESS \C or capital in search
|
|
||||||
vim.o.ignorecase = true
|
|
||||||
vim.o.smartcase = true
|
|
||||||
|
|
||||||
-- Keep signcolumn on by default
|
|
||||||
vim.wo.signcolumn = 'yes'
|
|
||||||
|
|
||||||
-- Decrease update time
|
|
||||||
vim.o.updatetime = 250
|
|
||||||
vim.o.timeout = true
|
|
||||||
vim.o.timeoutlen = 300
|
|
||||||
|
|
||||||
-- Set completeopt to have a better completion experience
|
|
||||||
vim.o.completeopt = 'menuone,noselect'
|
|
||||||
|
|
||||||
-- NOTE: You should make sure your terminal supports this
|
|
||||||
vim.o.termguicolors = true
|
|
||||||
|
|
||||||
-- [[ Basic Keymaps ]]
|
|
||||||
|
|
||||||
-- Keymaps for better default experience
|
|
||||||
-- See `:help vim.keymap.set()`
|
|
||||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
|
||||||
|
|
||||||
-- 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 })
|
|
||||||
|
|
||||||
-- [[ Highlight on yank ]]
|
|
||||||
-- See `:help vim.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 = '*',
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
-- import telescope actions safely
|
|
||||||
local actions_setup, actions = pcall(require, "telescope.actions")
|
|
||||||
if not actions_setup then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
--
|
|
||||||
-- [[ Configure Telescope ]]
|
|
||||||
-- See `:help telescope` and `:help telescope.setup()`
|
|
||||||
require('telescope').setup {
|
|
||||||
defaults = {
|
|
||||||
mappings = {
|
|
||||||
i = {
|
|
||||||
['<C-u>'] = false,
|
|
||||||
['<C-d>'] = false,
|
|
||||||
|
|
||||||
["<C-n>"] = actions.cycle_history_next,
|
|
||||||
["<C-p>"] = actions.cycle_history_prev,
|
|
||||||
|
|
||||||
["<C-j>"] = actions.move_selection_next,
|
|
||||||
["<C-k>"] = actions.move_selection_previous,
|
|
||||||
|
|
||||||
["<C-c>"] = actions.close,
|
|
||||||
|
|
||||||
["<Down>"] = actions.move_selection_next,
|
|
||||||
["<Up>"] = actions.move_selection_previous,
|
|
||||||
|
|
||||||
["<CR>"] = actions.select_default,
|
|
||||||
["<C-x>"] = actions.select_horizontal,
|
|
||||||
["<C-v>"] = actions.select_vertical,
|
|
||||||
["<C-t>"] = actions.select_tab,
|
|
||||||
|
|
||||||
-- ["<C-u>"] = actions.preview_scrolling_up,
|
|
||||||
-- ["<C-d>"] = actions.preview_scrolling_down,
|
|
||||||
|
|
||||||
["<PageUp>"] = actions.results_scrolling_up,
|
|
||||||
["<PageDown>"] = actions.results_scrolling_down,
|
|
||||||
|
|
||||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
|
||||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
|
||||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
|
||||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
|
||||||
["<C-l>"] = actions.complete_tag,
|
|
||||||
["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
n = {
|
|
||||||
["<esc>"] = actions.close,
|
|
||||||
["<CR>"] = actions.select_default,
|
|
||||||
["<C-x>"] = actions.select_horizontal,
|
|
||||||
["<C-v>"] = actions.select_vertical,
|
|
||||||
["<C-t>"] = actions.select_tab,
|
|
||||||
|
|
||||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
|
||||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
|
||||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
|
||||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
|
||||||
|
|
||||||
["j"] = actions.move_selection_next,
|
|
||||||
["k"] = actions.move_selection_previous,
|
|
||||||
["H"] = actions.move_to_top,
|
|
||||||
["M"] = actions.move_to_middle,
|
|
||||||
["L"] = actions.move_to_bottom,
|
|
||||||
|
|
||||||
["<Down>"] = actions.move_selection_next,
|
|
||||||
["<Up>"] = actions.move_selection_previous,
|
|
||||||
["gg"] = actions.move_to_top,
|
|
||||||
["G"] = actions.move_to_bottom,
|
|
||||||
|
|
||||||
["<C-u>"] = actions.preview_scrolling_up,
|
|
||||||
["<C-d>"] = actions.preview_scrolling_down,
|
|
||||||
|
|
||||||
["<PageUp>"] = actions.results_scrolling_up,
|
|
||||||
["<PageDown>"] = actions.results_scrolling_down,
|
|
||||||
|
|
||||||
["?"] = actions.which_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Enable telescope fzf native, if installed
|
|
||||||
pcall(require('telescope').load_extension, 'fzf')
|
|
||||||
|
|
||||||
-- 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' })
|
|
||||||
vim.keymap.set('n', '<leader>/', 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 {
|
|
||||||
winblend = 10,
|
|
||||||
previewer = false,
|
|
||||||
})
|
|
||||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
|
||||||
|
|
||||||
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>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
|
||||||
|
|
||||||
-- [[ 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', 'typescript', 'vimdoc', 'vim' },
|
|
||||||
|
|
||||||
-- 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 = {
|
|
||||||
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 = {
|
|
||||||
['<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 ]]
|
|
||||||
-- This function gets run when an LSP connects to a particular buffer.
|
|
||||||
local on_attach = function(_, bufnr)
|
|
||||||
-- 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 nmap = function(keys, func, desc)
|
|
||||||
if desc then
|
|
||||||
desc = 'LSP: ' .. desc
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
|
||||||
end
|
|
||||||
|
|
||||||
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('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
|
||||||
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
|
||||||
nmap('<leader>D', vim.lsp.buf.type_definition, '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')
|
|
||||||
|
|
||||||
-- See `:help K` for why this keymap
|
|
||||||
-- nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
|
||||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
|
||||||
|
|
||||||
-- Lesser used LSP functionality
|
|
||||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
|
||||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
|
||||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
|
||||||
nmap('<leader>wl', function()
|
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
||||||
end, '[W]orkspace [L]ist Folders')
|
|
||||||
|
|
||||||
-- Create a command `:Format` local to the LSP buffer
|
|
||||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
|
||||||
vim.lsp.buf.format()
|
|
||||||
end, { desc = 'Format current buffer with LSP' })
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 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. They will be passed to
|
|
||||||
-- the `settings` field of the server config. You must look up that documentation yourself.
|
|
||||||
local servers = {
|
|
||||||
-- clangd = {},
|
|
||||||
-- gopls = {},
|
|
||||||
-- pyright = {},
|
|
||||||
-- rust_analyzer = {},
|
|
||||||
-- tsserver = {},
|
|
||||||
|
|
||||||
lua_ls = {
|
|
||||||
Lua = {
|
|
||||||
workspace = { checkThirdParty = false },
|
|
||||||
telemetry = { enable = false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Setup neovim lua configuration
|
|
||||||
require('neodev').setup()
|
|
||||||
|
|
||||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
|
||||||
|
|
||||||
-- Ensure the servers above are installed
|
|
||||||
local mason_lspconfig = require 'mason-lspconfig'
|
|
||||||
|
|
||||||
mason_lspconfig.setup {
|
|
||||||
ensure_installed = vim.tbl_keys(servers),
|
|
||||||
}
|
|
||||||
|
|
||||||
mason_lspconfig.setup_handlers {
|
|
||||||
function(server_name)
|
|
||||||
require('lspconfig')[server_name].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = servers[server_name],
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- [[ Configure nvim-cmp ]]
|
|
||||||
-- See `:help cmp`
|
|
||||||
local cmp = require 'cmp'
|
|
||||||
local luasnip = require 'luasnip'
|
|
||||||
require('luasnip.loaders.from_vscode').lazy_load()
|
|
||||||
luasnip.config.setup {}
|
|
||||||
|
|
||||||
cmp.setup {
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
luasnip.lsp_expand(args.body)
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -907,7 +568,7 @@ cmp.setup {
|
||||||
|
|
||||||
-- Opens a popup that displays documentation about the word under your cursor
|
-- Opens a popup that displays documentation about the word under your cursor
|
||||||
-- See `:help K` for why this keymap.
|
-- See `:help K` for why this keymap.
|
||||||
map('K', vim.lsp.buf.hover, 'Hover Documentation')
|
-- map('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||||
|
|
||||||
-- WARN: This is not Goto Definition, this is Goto Declaration.
|
-- WARN: This is not Goto Definition, this is Goto Declaration.
|
||||||
-- For example, in C this would take you to the header.
|
-- For example, in C this would take you to the header.
|
||||||
|
|
|
@ -63,30 +63,30 @@ keymap.set('n', '<C-F2>', ':BookmarkToggle<CR>')
|
||||||
-- PLUGINS
|
-- PLUGINS
|
||||||
|
|
||||||
-- vim-maximizer
|
-- vim-maximizer
|
||||||
keymap.set("n", "<leader>sm", ":MaximizerToggle<CR>") -- toggle split window maximization
|
-- keymap.set("n", "<leader>sm", ":MaximizerToggle<CR>") -- toggle split window maximization
|
||||||
|
|
||||||
-- nvim-tree
|
-- nvim-tree
|
||||||
keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>") -- toggle file explorer
|
-- keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>") -- toggle file explorer
|
||||||
|
|
||||||
-- telescope
|
-- telescope
|
||||||
keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>") -- find files within current working directory, respects .gitignore
|
-- keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>") -- find files within current working directory, respects .gitignore
|
||||||
keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>") -- find string in current working directory as you type
|
-- keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>") -- find string in current working directory as you type
|
||||||
keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>") -- find string under cursor in current working directory
|
-- keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>") -- find string under cursor in current working directory
|
||||||
keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>") -- list open buffers in current neovim instance
|
-- keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>") -- list open buffers in current neovim instance
|
||||||
keymap.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>") -- list available help tags
|
-- keymap.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>") -- list available help tags
|
||||||
|
|
||||||
keymap.set("n", "<leader>t", "<cmd>Telescope vim_bookmarks current_file<cr>")
|
-- keymap.set("n", "<leader>t", "<cmd>Telescope vim_bookmarks current_file<cr>")
|
||||||
keymap.set("n", "<leader>tt", "<cmd>Telescope vim_bookmarks all<cr>")
|
-- keymap.set("n", "<leader>tt", "<cmd>Telescope vim_bookmarks all<cr>")
|
||||||
|
|
||||||
|
|
||||||
-- telescope git commands (not on youtube nvim video)
|
-- telescope git commands (not on youtube nvim video)
|
||||||
keymap.set("n", "<leader>gc", "<cmd>Telescope git_commits<cr>") -- list all git commits (use <cr> to checkout) ["gc" for git commits]
|
-- keymap.set("n", "<leader>gc", "<cmd>Telescope git_commits<cr>") -- list all git commits (use <cr> to checkout) ["gc" for git commits]
|
||||||
keymap.set("n", "<leader>gfc", "<cmd>Telescope git_bcommits<cr>") -- list git commits for current file/buffer (use <cr> to checkout) ["gfc" for git file commits]
|
-- keymap.set("n", "<leader>gfc", "<cmd>Telescope git_bcommits<cr>") -- list git commits for current file/buffer (use <cr> to checkout) ["gfc" for git file commits]
|
||||||
keymap.set("n", "<leader>gb", "<cmd>Telescope git_branches<cr>") -- list git branches (use <cr> to checkout) ["gb" for git branch]
|
-- keymap.set("n", "<leader>gb", "<cmd>Telescope git_branches<cr>") -- list git branches (use <cr> to checkout) ["gb" for git branch]
|
||||||
keymap.set("n", "<leader>gs", "<cmd>Telescope git_status<cr>") -- list current changes per file with diff preview ["gs" for git status]
|
-- keymap.set("n", "<leader>gs", "<cmd>Telescope git_status<cr>") -- list current changes per file with diff preview ["gs" for git status]
|
||||||
|
|
||||||
-- restart lsp server (not on youtube nvim video)
|
-- restart lsp server (not on youtube nvim video)
|
||||||
keymap.set("n", "<leader>rs", ":LspRestart<CR>") -- mapping to restart lsp if necessary
|
-- keymap.set("n", "<leader>rs", ":LspRestart<CR>") -- mapping to restart lsp if necessary
|
||||||
|
|
||||||
-- move
|
-- move
|
||||||
local opts = { noremap = true, silent = false }
|
local opts = { noremap = true, silent = false }
|
||||||
|
|
|
@ -1,110 +0,0 @@
|
||||||
return {
|
|
||||||
'nvim-telescope/telescope.nvim',
|
|
||||||
version = '*',
|
|
||||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
|
||||||
cmd = { 'Telescope' },
|
|
||||||
config = function()
|
|
||||||
local actions = require "telescope.actions"
|
|
||||||
require('telescope').setup {
|
|
||||||
defaults = {
|
|
||||||
path_display = { "smart" },
|
|
||||||
mappings = {
|
|
||||||
i = {
|
|
||||||
["<C-n>"] = actions.cycle_history_next,
|
|
||||||
["<C-p>"] = actions.cycle_history_prev,
|
|
||||||
|
|
||||||
["<C-j>"] = actions.move_selection_next,
|
|
||||||
["<C-k>"] = actions.move_selection_previous,
|
|
||||||
|
|
||||||
["<C-c>"] = actions.close,
|
|
||||||
|
|
||||||
["<Down>"] = actions.move_selection_next,
|
|
||||||
["<Up>"] = actions.move_selection_previous,
|
|
||||||
|
|
||||||
["<CR>"] = actions.select_default,
|
|
||||||
["<C-x>"] = actions.select_horizontal,
|
|
||||||
["<C-v>"] = actions.select_vertical,
|
|
||||||
["<C-t>"] = actions.select_tab,
|
|
||||||
|
|
||||||
["<C-u>"] = actions.preview_scrolling_up,
|
|
||||||
["<C-d>"] = actions.preview_scrolling_down,
|
|
||||||
|
|
||||||
["<PageUp>"] = actions.results_scrolling_up,
|
|
||||||
["<PageDown>"] = actions.results_scrolling_down,
|
|
||||||
|
|
||||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
|
||||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
|
||||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
|
||||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
|
||||||
["<C-l>"] = actions.complete_tag,
|
|
||||||
["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
|
|
||||||
},
|
|
||||||
|
|
||||||
n = {
|
|
||||||
["<esc>"] = actions.close,
|
|
||||||
["<CR>"] = actions.select_default,
|
|
||||||
["<C-x>"] = actions.select_horizontal,
|
|
||||||
["<C-v>"] = actions.select_vertical,
|
|
||||||
["<C-t>"] = actions.select_tab,
|
|
||||||
|
|
||||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
|
||||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
|
||||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
|
||||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
|
||||||
|
|
||||||
["j"] = actions.move_selection_next,
|
|
||||||
["k"] = actions.move_selection_previous,
|
|
||||||
["H"] = actions.move_to_top,
|
|
||||||
["M"] = actions.move_to_middle,
|
|
||||||
["L"] = actions.move_to_bottom,
|
|
||||||
|
|
||||||
["<Down>"] = actions.move_selection_next,
|
|
||||||
["<Up>"] = actions.move_selection_previous,
|
|
||||||
["gg"] = actions.move_to_top,
|
|
||||||
["G"] = actions.move_to_bottom,
|
|
||||||
|
|
||||||
["<C-u>"] = actions.preview_scrolling_up,
|
|
||||||
["<C-d>"] = actions.preview_scrolling_down,
|
|
||||||
|
|
||||||
["<PageUp>"] = actions.results_scrolling_up,
|
|
||||||
["<PageDown>"] = actions.results_scrolling_down,
|
|
||||||
|
|
||||||
["?"] = actions.which_key,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
pickers = {
|
|
||||||
-- Default configuration for builtin pickers goes here:
|
|
||||||
-- picker_name = {
|
|
||||||
-- picker_config_key = value,
|
|
||||||
-- ...
|
|
||||||
-- }
|
|
||||||
-- Now the picker_config_key will be applied every time you call this
|
|
||||||
-- builtin picker
|
|
||||||
},
|
|
||||||
extensions = {
|
|
||||||
file_browser = {
|
|
||||||
-- theme = "ivy",
|
|
||||||
-- require("telescope.themes").get_dropdown {
|
|
||||||
-- previewer = false,
|
|
||||||
-- -- even more opts
|
|
||||||
-- },
|
|
||||||
mappings = {
|
|
||||||
["i"] = {
|
|
||||||
-- your custom insert mode mappings
|
|
||||||
},
|
|
||||||
["n"] = {
|
|
||||||
-- your custom normal mode mappings
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
["ui-select"] = {
|
|
||||||
require("telescope.themes").get_dropdown {
|
|
||||||
previewer = false,
|
|
||||||
-- even more opts
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}
|
|
Loading…
Reference in New Issue