Add buffer completion source to nvim-cmp plugin in defaults.lua and integrate lspsaga.nvim plugin for LSP functionality in keymaps.lua and init.lua
This commit is contained in:
parent
4106e4f395
commit
ef91f14af8
|
@ -10,5 +10,3 @@ vim.opt.scrolloff = 8
|
||||||
vim.opt.colorcolumn = "80"
|
vim.opt.colorcolumn = "80"
|
||||||
|
|
||||||
vim.opt.swapfile = false
|
vim.opt.swapfile = false
|
||||||
|
|
||||||
vim.o.cmdheight = 2
|
|
||||||
|
|
|
@ -47,8 +47,8 @@ keymap('n', '<leader>y', "\"+y", { desc = "[Y]ank to clipboard" })
|
||||||
keymap('v', '<leader>y', "\"+y", { desc = "[Y]ank to clipboard" })
|
keymap('v', '<leader>y', "\"+y", { desc = "[Y]ank to clipboard" })
|
||||||
keymap('n', '<leader>Y', "\"+Y", { desc = "[Y]ank to clipboard" })
|
keymap('n', '<leader>Y', "\"+Y", { desc = "[Y]ank to clipboard" })
|
||||||
|
|
||||||
-- Open folder in workspace in tmux session
|
-- -- Open folder in workspace in tmux session
|
||||||
keymap("n", "<leader>op", "<cmd>silent !tmux neww tmux-sessionizer<CR>", { desc = "[O]pen [P]roject" })
|
-- keymap("n", "<leader>op", "<cmd>silent !tmux neww tmux-sessionizer<CR>", { desc = "[O]pen [P]roject" })
|
||||||
|
|
||||||
-- Search cheat sheet
|
-- Search cheat sheet
|
||||||
keymap("n", "<leader>ch", "<cmd>silent !tmux neww tmux-cht.sh<CR>", { desc = "[C]heat [S]heet" })
|
keymap("n", "<leader>ch", "<cmd>silent !tmux neww tmux-cht.sh<CR>", { desc = "[C]heat [S]heet" })
|
||||||
|
|
43
init.lua
43
init.lua
|
@ -98,7 +98,7 @@ require('lazy').setup({
|
||||||
{
|
{
|
||||||
-- Autocompletion
|
-- Autocompletion
|
||||||
'hrsh7th/nvim-cmp',
|
'hrsh7th/nvim-cmp',
|
||||||
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' },
|
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-buffer' },
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Useful plugin to show you pending keybinds.
|
-- Useful plugin to show you pending keybinds.
|
||||||
|
@ -186,6 +186,19 @@ require('lazy').setup({
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"glepnir/lspsaga.nvim",
|
||||||
|
event = "LspAttach",
|
||||||
|
dependencies = {
|
||||||
|
{ "nvim-tree/nvim-web-devicons" },
|
||||||
|
--Please make sure you install markdown and markdown_inline parser
|
||||||
|
{ "nvim-treesitter/nvim-treesitter" }
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require("lspsaga").setup({})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
-- 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.
|
-- These are some example plugins that I've included in the kickstart repository.
|
||||||
-- Uncomment any of the lines below to enable them.
|
-- Uncomment any of the lines below to enable them.
|
||||||
|
@ -302,7 +315,7 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
|
||||||
-- See `:help nvim-treesitter`
|
-- See `:help nvim-treesitter`
|
||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim' },
|
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim', 'markdown', 'markdown_inline' },
|
||||||
|
|
||||||
-- 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 = true,
|
auto_install = true,
|
||||||
|
@ -387,18 +400,29 @@ local on_attach = function(_, bufnr)
|
||||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||||
end
|
end
|
||||||
|
|
||||||
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('<leader>rn', ":Lspsaga rename<CR>", '[R]e[n]ame')
|
||||||
|
nmap('<leader>ca', ":Lspsaga code_action<CR>", '[C]ode [A]ction')
|
||||||
|
|
||||||
|
-- nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
||||||
|
nmap("gp", ":Lspsaga peek_definition<CR>", "[gP]eek [D]efinition")
|
||||||
|
nmap('gd', ":Lspsaga goto_definition<CR>", '[G]oto [D]efinition')
|
||||||
|
nmap('gh', ":Lspsaga lsp_finder<CR>", '[G]oto [H]elp')
|
||||||
|
|
||||||
|
|
||||||
nmap('gd', vim.lsp.buf.definition, '[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', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
||||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
|
||||||
|
-- nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||||
|
nmap('<leader>D', ":Lspsaga peek_type_definition<CR>", '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')
|
||||||
|
|
||||||
-- See `:help K` for why this keymap
|
-- See `:help K` for why this keymap
|
||||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
-- nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||||
|
nmap('K', ":Lspsaga hover_doc<CR>", 'Hover Documentation')
|
||||||
-- nmap('<C-K>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
-- nmap('<C-K>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||||
|
|
||||||
-- Lesser used LSP functionality
|
-- Lesser used LSP functionality
|
||||||
|
@ -409,6 +433,10 @@ local on_attach = function(_, bufnr)
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
end, '[W]orkspace [L]ist Folders')
|
end, '[W]orkspace [L]ist Folders')
|
||||||
|
|
||||||
|
|
||||||
|
-- Toggle outline
|
||||||
|
nkeymap("<leader>o", ":Lspsaga outline<CR>", '[O]utline')
|
||||||
|
|
||||||
-- Create a command `:Format` local to the LSP buffer
|
-- Create a command `:Format` local to the LSP buffer
|
||||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||||
vim.lsp.buf.format()
|
vim.lsp.buf.format()
|
||||||
|
@ -504,6 +532,7 @@ cmp.setup {
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
|
{ name = 'buffer' },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue