feat(plugins): clean up
This commit is contained in:
parent
9211e64849
commit
ff3a7a5de4
4 changed files with 45 additions and 42 deletions
|
@ -2,7 +2,6 @@ local M = {}
|
||||||
|
|
||||||
M.init = function()
|
M.init = function()
|
||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
local luasnip = require('luasnip')
|
|
||||||
|
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
autocmd FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false }
|
autocmd FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false }
|
||||||
|
@ -16,7 +15,7 @@ M.init = function()
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
luasnip.lsp_expand(args.body)
|
require('luasnip').lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = {
|
mapping = {
|
||||||
|
@ -35,8 +34,8 @@ M.init = function()
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
elseif luasnip.expand_or_jumpable() then
|
elseif require('luasnip').expand_or_jumpable() then
|
||||||
luasnip.expand_or_jump()
|
require('luasnip').expand_or_jump()
|
||||||
elseif has_words_before() then
|
elseif has_words_before() then
|
||||||
cmp.complete()
|
cmp.complete()
|
||||||
else
|
else
|
||||||
|
@ -49,8 +48,8 @@ M.init = function()
|
||||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
elseif luasnip.jumpable(-1) then
|
elseif require('luasnip').jumpable(-1) then
|
||||||
luasnip.jump(-1)
|
require('luasnip').jump(-1)
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,19 +37,19 @@ function M.on_attach(client, bufnr)
|
||||||
client.resolved_capabilities.document_range_formatting = false
|
client.resolved_capabilities.document_range_formatting = false
|
||||||
end
|
end
|
||||||
|
|
||||||
require('lsp_signature').on_attach({
|
--[[ require('lsp_signature').on_attach({
|
||||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||||
handler_opts = {
|
handler_opts = {
|
||||||
border = 'single',
|
border = 'single',
|
||||||
},
|
},
|
||||||
}, bufnr)
|
}, bufnr) ]]
|
||||||
end
|
end
|
||||||
|
|
||||||
M.flags = {
|
M.flags = {
|
||||||
debounce_text_changes = 150,
|
debounce_text_changes = 150,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function get_capabilities()
|
--[[ local function get_capabilities()
|
||||||
local ok, cmp_nvim_lsp = pcall(require, 'cmp_nvim_lsp')
|
local ok, cmp_nvim_lsp = pcall(require, 'cmp_nvim_lsp')
|
||||||
if not ok then
|
if not ok then
|
||||||
return {}
|
return {}
|
||||||
|
@ -57,7 +57,8 @@ local function get_capabilities()
|
||||||
return cmp_nvim_lsp.update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
return cmp_nvim_lsp.update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
end
|
end
|
||||||
|
|
||||||
M.capabilities = get_capabilities()
|
M.capabilities = get_capabilities() ]]
|
||||||
|
M.capabilities = {}
|
||||||
|
|
||||||
M.root_dir = function(fname)
|
M.root_dir = function(fname)
|
||||||
local util = require('lspconfig').util
|
local util = require('lspconfig').util
|
||||||
|
|
|
@ -35,7 +35,6 @@ for config_server, config_opt in pairs(config.lsp.servers) do
|
||||||
table.insert(disabled_servers, config_server)
|
table.insert(disabled_servers, config_server)
|
||||||
elseif not vim.tbl_contains(requested_servers, config_server) then
|
elseif not vim.tbl_contains(requested_servers, config_server) then
|
||||||
-- add additonally defined servers to be installed
|
-- add additonally defined servers to be installed
|
||||||
-- todo: how to handle non-default server opts?
|
|
||||||
table.insert(requested_servers, config_server)
|
table.insert(requested_servers, config_server)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -91,27 +91,25 @@ return packer.startup(function()
|
||||||
|
|
||||||
use({
|
use({
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
|
config = function()
|
||||||
|
require('cosmic.lsp')
|
||||||
|
end,
|
||||||
requires = {
|
requires = {
|
||||||
{
|
{
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'ray-x/lsp_signature.nvim',
|
||||||
|
config = function()
|
||||||
|
-- must happen after servers are set up
|
||||||
|
require('lsp_signature').setup({
|
||||||
|
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||||
|
handler_opts = {
|
||||||
|
border = 'rounded',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
after = 'nvim-lspconfig',
|
after = 'nvim-lspconfig',
|
||||||
},
|
},
|
||||||
{
|
{ 'jose-elias-alvarez/nvim-lsp-ts-utils' },
|
||||||
'jose-elias-alvarez/nvim-lsp-ts-utils',
|
{ 'williamboman/nvim-lsp-installer' },
|
||||||
after = 'cmp-nvim-lsp',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'ray-x/lsp_signature.nvim',
|
|
||||||
after = 'nvim-lsp-ts-utils',
|
|
||||||
},
|
|
||||||
{ 'onsails/lspkind-nvim', after = 'lsp_signature.nvim' },
|
|
||||||
{
|
|
||||||
'williamboman/nvim-lsp-installer',
|
|
||||||
after = 'lspkind-nvim',
|
|
||||||
config = function()
|
|
||||||
require('cosmic.lsp')
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -121,18 +119,12 @@ return packer.startup(function()
|
||||||
require('cosmic.lsp.providers.null_ls')
|
require('cosmic.lsp.providers.null_ls')
|
||||||
end,
|
end,
|
||||||
requires = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
|
requires = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
|
||||||
|
disable = vim.tbl_contains(user_plugins.disable, 'null-ls'),
|
||||||
})
|
})
|
||||||
|
|
||||||
use({
|
use({
|
||||||
'L3MON4D3/LuaSnip',
|
'onsails/lspkind-nvim',
|
||||||
config = function()
|
event = 'InsertEnter',
|
||||||
require('cosmic.core.snippets')
|
|
||||||
end,
|
|
||||||
requires = {
|
|
||||||
{
|
|
||||||
'rafamadriz/friendly-snippets',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
|
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -143,20 +135,32 @@ return packer.startup(function()
|
||||||
require('cosmic.lsp.autocomplete').init()
|
require('cosmic.lsp.autocomplete').init()
|
||||||
end,
|
end,
|
||||||
requires = {
|
requires = {
|
||||||
{ 'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp' },
|
{ 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' },
|
||||||
|
{ 'saadparwaiz1/cmp_luasnip', after = 'cmp-nvim-lsp' },
|
||||||
{ 'hrsh7th/cmp-buffer', after = 'cmp_luasnip' },
|
{ 'hrsh7th/cmp-buffer', after = 'cmp_luasnip' },
|
||||||
{ 'hrsh7th/cmp-nvim-lua', after = 'cmp-buffer' },
|
{ 'hrsh7th/cmp-nvim-lua', after = 'cmp-buffer' },
|
||||||
{ 'hrsh7th/cmp-path', after = 'cmp-nvim-lua' },
|
{ 'hrsh7th/cmp-path', after = 'cmp-nvim-lua' },
|
||||||
|
{
|
||||||
|
'windwp/nvim-autopairs',
|
||||||
|
config = function()
|
||||||
|
require('cosmic.lsp.autocomplete').autopairs()
|
||||||
|
end,
|
||||||
|
after = 'cmp-path',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
event = 'InsertEnter',
|
after = 'lspkind-nvim',
|
||||||
|
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
|
||||||
})
|
})
|
||||||
|
|
||||||
use({
|
use({
|
||||||
'windwp/nvim-autopairs',
|
'L3MON4D3/LuaSnip',
|
||||||
config = function()
|
config = function()
|
||||||
require('cosmic.lsp.autocomplete').autopairs()
|
require('cosmic.core.snippets')
|
||||||
end,
|
end,
|
||||||
after = 'nvim-cmp',
|
requires = {
|
||||||
|
'rafamadriz/friendly-snippets',
|
||||||
|
},
|
||||||
|
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- git commands
|
-- git commands
|
||||||
|
|
Loading…
Add table
Reference in a new issue