feat: clean up luasnip
This commit is contained in:
parent
a98a8d3612
commit
33bd78ed9f
7 changed files with 57 additions and 65 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
|
||||
"LuaSnip": { "branch": "master", "commit": "2b6860d15aaab01d3fb90859c0ba97f20ad7bc5f" },
|
||||
"LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" },
|
||||
"SchemaStore.nvim": { "branch": "main", "commit": "d9fd6651b47b68bfc1b952f81a0fdded3cb205b2" },
|
||||
"auto-session": { "branch": "main", "commit": "af2219b9fa99c1d7ac409bd9eac094c459d3f52d" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
|
@ -10,37 +10,36 @@
|
|||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"cosmic-ui": { "branch": "main", "commit": "c0b14531999f2bfef3d927c4dcd57a1a8fed5ee9" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "e11b09bf10706bb74e16e4c3d11b2274d62e687f" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "379a5a915aea3e9ba0d4a778e8478584ac0f9011" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "70f2c090d3ffb14f8702d468e05beb240b768881" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "4a143f13e122ab91abdc88f89eefbe70a4858a56" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "a4caa0d083aab56f6cd5acf2d42331b74614a585" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "8db12610bcb7ce67013cfdfaba4dd47a23c6e851" },
|
||||
"mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "02893eeb9d6e8503817bd52385e111cba9a90500" },
|
||||
"noice.nvim": { "branch": "main", "commit": "29c7f030b0920e2f17263a9ab8742cde144b9140" },
|
||||
"noice.nvim": { "branch": "main", "commit": "e5cb20c6e14305d24025ecb77d7d4dd9d61f1a64" },
|
||||
"none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" },
|
||||
"none-ls-shellcheck.nvim": { "branch": "main", "commit": "0f84461241e76e376a95fb7391deac82dc3efdbf" },
|
||||
"none-ls.nvim": { "branch": "main", "commit": "8691504118b252d64fc5023a104aedd100ab754a" },
|
||||
"nui.nvim": { "branch": "main", "commit": "322978c734866996274467de084a95e4f9b5e0b1" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
|
||||
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "92166b89ab4b3d60f24e58170cac53b7141fd032" },
|
||||
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "26632f496e7e3c0450d8ecff88f49068cecc8bda" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "3a74b5831058d0daf8952a5b8c556c61b30a3f46" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "c1e1e24b6433d4539bad9f5daa207df39633071b" },
|
||||
"nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "6eb4120a1aadef07ac312f1c4bc6456712220007" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "b77921fdc44833c994fdb389d658ccbce5490c16" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "b4b302d6ae229f67df7a87ef69fa79473fe788a9" },
|
||||
"nx.nvim": { "branch": "main", "commit": "f8a3a21b3d540889401a40d1f2803083794c0372" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
|
||||
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "dfa230be84a044e7f546a6c2b0a403c739732b86" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "3a743491e5c6be0ed0aa8c31c6905df8f66179ba" },
|
||||
"todo-comments.nvim": { "branch": "main", "commit": "70a93ce66083699571adc361166504b03cc39c2b" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "9d88650502bc331f43eb0bef6286e58144ac5a96" },
|
||||
"typescript-tools.nvim": { "branch": "master", "commit": "c43d9580c3ff5999a1eabca849f807ab33787ea7" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "f9e738e2dc78326166f11c021171b2e66a2ee426" },
|
||||
"vim-floaterm": { "branch": "master", "commit": "4e28c8dd0271e10a5f55142fb6fe9b1599ee6160" },
|
||||
"vim-fugitive": { "branch": "master", "commit": "4f59455d2388e113bd510e85b310d15b9228ca0d" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "0539da005b98b02cf730c1d9da82b8e8edb1c2d2" }
|
||||
"which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }
|
||||
}
|
|
@ -7,13 +7,4 @@ return {
|
|||
command = 'EslintFixAll',
|
||||
})
|
||||
end,
|
||||
|
||||
settings = {
|
||||
-- helps eslint find the eslintrc when it's placed in a subfolder instead of the cwd root
|
||||
workingDirectories = { mode = 'auto' },
|
||||
-- allows to use flat config format
|
||||
--[[ experimental = { ]]
|
||||
--[[ useFlatConfig = true, ]]
|
||||
--[[ }, ]]
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
return {
|
||||
'L3MON4D3/LuaSnip',
|
||||
config = function()
|
||||
local ls = require('luasnip')
|
||||
ls.config.set_config(u.merge({
|
||||
history = true,
|
||||
-- Update more often, :h events for more info.
|
||||
updateevents = 'TextChanged,TextChangedI',
|
||||
enable_autosnippets = true,
|
||||
}, user_config.plugins.luasnip or {}))
|
||||
|
||||
-- extend html snippets to react files
|
||||
require('luasnip').filetype_extend('javascriptreact', { 'html' })
|
||||
require('luasnip').filetype_extend('typescriptreact', { 'html' })
|
||||
|
||||
-- load snippets (friendly-snippets)
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
end,
|
||||
dependencies = {
|
||||
'rafamadriz/friendly-snippets',
|
||||
},
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'luasnip'),
|
||||
}
|
|
@ -17,7 +17,7 @@ return {
|
|||
local lspconfig = require('lspconfig')
|
||||
|
||||
local start_server = function(server)
|
||||
-- null_ls doesn't need/can't to be started via lspconfig
|
||||
-- don't match servers not started by lspconfig
|
||||
if server == 'null_ls' or server == 'typescript-tools' then
|
||||
return
|
||||
end
|
||||
|
@ -37,7 +37,7 @@ return {
|
|||
opts = u.merge(opts, require('cosmic.lsp.providers.lua_ls'))
|
||||
end
|
||||
|
||||
-- override options if user definds them
|
||||
-- override options if user defines them
|
||||
if type(user_config.lsp.servers[server]) == 'table' then
|
||||
if user_config.lsp.servers[server].opts ~= nil then
|
||||
opts = u.merge(opts, user_config.lsp.servers[server].opts)
|
||||
|
|
|
@ -25,9 +25,6 @@ return {
|
|||
config_opts.sources = u.merge_list({
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
null_ls.builtins.diagnostics.markdownlint,
|
||||
--[[ require('none-ls.diagnostics.eslint_d'), ]]
|
||||
--[[ require('none-ls.formatting.eslint_d'), ]]
|
||||
--[[ require('none-ls.code_actions.eslint_d'), ]]
|
||||
null_ls.builtins.formatting.prettierd.with({
|
||||
env = {
|
||||
PRETTIERD_LOCAL_PRETTIER_ONLY = 1,
|
||||
|
@ -41,7 +38,6 @@ return {
|
|||
null_ls.setup(u.merge(defaults, config_opts))
|
||||
end,
|
||||
--[[ event = 'BufEnter', ]]
|
||||
--[[ event = 'VeryLazy', ]]
|
||||
lazy = false,
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'null_ls'),
|
||||
}
|
||||
|
|
|
@ -1,16 +1,27 @@
|
|||
local cmp = require('cmp')
|
||||
local u = require('cosmic.utils')
|
||||
local luasnip = require('luasnip')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local icons = require('cosmic.utils.icons')
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
|
||||
local user_has_luasnip = not vim.tbl_contains(user_config.disable_builtin_plugins, 'luasnip')
|
||||
local _, luasnip = pcall(require, 'luasnip')
|
||||
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
|
||||
end
|
||||
|
||||
local snippet = {}
|
||||
if user_has_luasnip then
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
local default_cmp_opts = {
|
||||
enabled = function()
|
||||
-- disable completion in comments
|
||||
|
@ -22,11 +33,7 @@ local default_cmp_opts = {
|
|||
return not context.in_treesitter_capture('comment') and not context.in_syntax_group('Comment')
|
||||
end
|
||||
end,
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
snippet = snippet,
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||
['<C-u>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||
|
@ -42,7 +49,7 @@ local default_cmp_opts = {
|
|||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
elseif user_has_luasnip and luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
|
@ -56,7 +63,7 @@ local default_cmp_opts = {
|
|||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
elseif user_has_luasnip and luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
|
@ -81,7 +88,7 @@ local default_cmp_opts = {
|
|||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
--[[ { name = 'luasnip' }, ]]
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'path' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
return {
|
||||
'hrsh7th/nvim-cmp',
|
||||
|
@ -7,12 +8,36 @@ return {
|
|||
end,
|
||||
dependencies = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
{
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'luasnip'),
|
||||
},
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
'hrsh7th/cmp-path',
|
||||
-- has configs
|
||||
'L3MON4D3/LuaSnip',
|
||||
{
|
||||
'L3MON4D3/LuaSnip',
|
||||
config = function()
|
||||
local ls = require('luasnip')
|
||||
ls.config.set_config(u.merge({
|
||||
history = true,
|
||||
-- Update more often, :h events for more info.
|
||||
updateevents = 'TextChanged,TextChangedI',
|
||||
enable_autosnippets = true,
|
||||
}, user_config.plugins.luasnip or {}))
|
||||
|
||||
-- extend html snippets to react files
|
||||
require('luasnip').filetype_extend('javascriptreact', { 'html' })
|
||||
require('luasnip').filetype_extend('typescriptreact', { 'html' })
|
||||
|
||||
-- load snippets (friendly-snippets)
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
end,
|
||||
dependencies = {
|
||||
'rafamadriz/friendly-snippets',
|
||||
},
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'luasnip'),
|
||||
},
|
||||
},
|
||||
event = 'InsertEnter',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-cmp'),
|
||||
|
|
Loading…
Add table
Reference in a new issue