-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add auto pairing and multiple cursor plugins
- Loading branch information
1 parent
d685992
commit c8af8e1
Showing
4 changed files
with
138 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
return { | ||
'windwp/nvim-autopairs', | ||
event = "InsertEnter", | ||
config = true | ||
-- use opts = {} for passing setup options | ||
-- this is equivalent to setup({}) function | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,136 @@ | ||
return { | ||
{ | ||
'williamboman/mason.nvim', | ||
lazy = false, | ||
opts = {}, | ||
}, | ||
|
||
-- Autocompletion | ||
{ | ||
'hrsh7th/nvim-cmp', | ||
event = 'InsertEnter', | ||
config = function() | ||
local cmp = require('cmp') | ||
{ | ||
'williamboman/mason.nvim', | ||
lazy = false, | ||
opts = {}, | ||
}, | ||
|
||
cmp.setup({ | ||
sources = { | ||
{ name = 'nvim_lsp' }, | ||
}, | ||
mapping = cmp.mapping.preset.insert({ | ||
['<C-Space>'] = cmp.mapping.complete(), | ||
['<C-u>'] = cmp.mapping.scroll_docs(-4), | ||
['<C-d>'] = cmp.mapping.scroll_docs(4), | ||
}), | ||
snippet = { | ||
expand = function(args) | ||
vim.snippet.expand(args.body) | ||
end, | ||
}, | ||
}) | ||
end | ||
}, | ||
-- Autocompletion | ||
{ | ||
'hrsh7th/nvim-cmp', | ||
event = 'InsertEnter', | ||
config = function() | ||
local cmp = require('cmp') | ||
|
||
-- LSP | ||
{ | ||
'neovim/nvim-lspconfig', | ||
cmd = { 'LspInfo', 'LspInstall', 'LspStart' }, | ||
event = { 'BufReadPre', 'BufNewFile' }, | ||
dependencies = { | ||
"williamboman/mason.nvim", | ||
"williamboman/mason-lspconfig.nvim", | ||
"hrsh7th/cmp-nvim-lsp", | ||
"hrsh7th/cmp-buffer", | ||
"hrsh7th/cmp-path", | ||
"hrsh7th/cmp-cmdline", | ||
"hrsh7th/nvim-cmp", | ||
"L3MON4D3/LuaSnip", | ||
"saadparwaiz1/cmp_luasnip", | ||
"j-hui/fidget.nvim", | ||
cmp.setup({ | ||
sources = { | ||
{ name = 'nvim_lsp' }, | ||
}, | ||
init = function() | ||
-- Reserve a space in the gutter | ||
-- This will avoid an annoying layout shift in the screen | ||
vim.opt.signcolumn = 'yes' | ||
end, | ||
mapping = cmp.mapping.preset.insert({ | ||
['<C-Space>'] = cmp.mapping.complete(), | ||
['<C-u>'] = cmp.mapping.scroll_docs(-4), | ||
['<C-d>'] = cmp.mapping.scroll_docs(4), | ||
}), | ||
snippet = { | ||
expand = function(args) | ||
vim.snippet.expand(args.body) | ||
end, | ||
}, | ||
}) | ||
end | ||
}, | ||
|
||
-- LSP | ||
{ | ||
'neovim/nvim-lspconfig', | ||
cmd = { 'LspInfo', 'LspInstall', 'LspStart' }, | ||
event = { 'BufReadPre', 'BufNewFile' }, | ||
dependencies = { | ||
"williamboman/mason.nvim", | ||
"williamboman/mason-lspconfig.nvim", | ||
"hrsh7th/cmp-nvim-lsp", | ||
"hrsh7th/cmp-buffer", | ||
"hrsh7th/cmp-path", | ||
"hrsh7th/cmp-cmdline", | ||
"hrsh7th/nvim-cmp", | ||
"L3MON4D3/LuaSnip", | ||
"saadparwaiz1/cmp_luasnip", | ||
"j-hui/fidget.nvim", | ||
}, | ||
init = function() | ||
-- Reserve a space in the gutter | ||
-- This will avoid an annoying layout shift in the screen | ||
vim.opt.signcolumn = 'yes' | ||
end, | ||
|
||
config = function() | ||
local lsp_defaults = require('lspconfig').util.default_config | ||
config = function() | ||
local lsp_defaults = require('lspconfig').util.default_config | ||
|
||
require('mason-lspconfig').setup({ | ||
ensure_installed = { "eslint" }, | ||
handlers = { | ||
-- this first function is the "default handler" | ||
-- it applies to every language server without a "custom handler" | ||
function(server_name) | ||
require('lspconfig')[server_name].setup({}) | ||
end, | ||
} | ||
}) | ||
require('mason-lspconfig').setup({ | ||
ensure_installed = { "eslint" }, | ||
handlers = { | ||
-- this first function is the "default handler" | ||
-- it applies to every language server without a "custom handler" | ||
function(server_name) | ||
require('lspconfig')[server_name].setup({}) | ||
end, | ||
} | ||
}) | ||
|
||
-- Add cmp_nvim_lsp capabilities settings to lspconfig | ||
-- This should be executed before you configure any language server | ||
lsp_defaults.capabilities = vim.tbl_deep_extend( | ||
'force', | ||
lsp_defaults.capabilities, | ||
require('cmp_nvim_lsp').default_capabilities() | ||
) | ||
-- Add cmp_nvim_lsp capabilities settings to lspconfig | ||
-- This should be executed before you configure any language server | ||
lsp_defaults.capabilities = vim.tbl_deep_extend( | ||
'force', | ||
lsp_defaults.capabilities, | ||
require('cmp_nvim_lsp').default_capabilities() | ||
) | ||
|
||
-- LspAttach is where you enable features that only work | ||
-- if there is a language server active in the file | ||
vim.api.nvim_create_autocmd('LspAttach', { | ||
desc = 'LSP actions', | ||
callback = function(event) | ||
local opts = { buffer = event.buf } | ||
-- LspAttach is where you enable features that only work | ||
-- if there is a language server active in the file | ||
vim.api.nvim_create_autocmd('LspAttach', { | ||
desc = 'LSP actions', | ||
callback = function(event) | ||
local opts = { buffer = event.buf } | ||
|
||
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts) | ||
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts) | ||
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts) | ||
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts) | ||
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts) | ||
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts) | ||
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts) | ||
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts) | ||
vim.keymap.set({ 'n', 'x' }, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts) | ||
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts) | ||
end, | ||
}) | ||
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts) | ||
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts) | ||
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts) | ||
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts) | ||
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts) | ||
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts) | ||
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts) | ||
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts) | ||
vim.keymap.set({ 'n', 'x' }, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts) | ||
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts) | ||
end, | ||
|
||
local cmp = require('cmp') | ||
local cmp_select = { behaviour = cmp.SelectBehavior.Select } | ||
}) | ||
|
||
cmp.setup({ | ||
sources = { | ||
{ name = 'nvim_lsp' }, | ||
{ name = 'luasnip' }, | ||
}, | ||
snippet = { | ||
expand = function(args) | ||
require('luasnip').lsp_expand(args.body) | ||
end, | ||
}, | ||
mapping = cmp.mapping.preset.insert({ | ||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), | ||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select), | ||
['<C-y>'] = cmp.mapping.confirm({ select = true }), | ||
['<C-Space>'] = cmp.mapping.complete(), | ||
}), | ||
}) | ||
vim.api.nvim_create_autocmd("CursorHold", { | ||
buffer = bufnr, | ||
callback = function() | ||
local opts = { | ||
focusable = false, | ||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, | ||
border = 'rounded', | ||
source = 'always', | ||
prefix = ' ', | ||
scope = 'cursor', | ||
} | ||
vim.diagnostic.open_float(nil, opts) | ||
end | ||
}, | ||
}) | ||
|
||
local cmp = require('cmp') | ||
local cmp_select = { behaviour = cmp.SelectBehavior.Select } | ||
|
||
cmp.setup({ | ||
sources = { | ||
{ name = 'nvim_lsp' }, | ||
{ name = 'luasnip' }, | ||
}, | ||
snippet = { | ||
expand = function(args) | ||
require('luasnip').lsp_expand(args.body) | ||
end, | ||
}, | ||
mapping = cmp.mapping.preset.insert({ | ||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), | ||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select), | ||
['<C-y>'] = cmp.mapping.confirm({ select = true }), | ||
['<C-Space>'] = cmp.mapping.complete(), | ||
}), | ||
}) | ||
end | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
return { | ||
"mg979/vim-visual-multi" | ||
} |