diff --git a/symlinks/config/nvim/lua/init/plugins.lua b/symlinks/config/nvim/lua/init/plugins.lua index 0a8d03a..410b802 100644 --- a/symlinks/config/nvim/lua/init/plugins.lua +++ b/symlinks/config/nvim/lua/init/plugins.lua @@ -23,10 +23,7 @@ return require("packer").startup { use "airblade/vim-gitgutter" -- Git signs use "godlygeek/tabular" -- Tabular command for alignment use "vim-scripts/utl.vim" -- Universal text linking - use { - "mbbill/undotree", - cmd = "UndotreeToggle" - } -- Undos in a tree for easy access + use {"mbbill/undotree", cmd = "UndotreeToggle"} -- Undos in a tree for easy access use "mhinz/vim-grepper" -- Grepper command - improved grepping throughout project use "radenling/vim-dispatch-neovim" -- vim-dispatch for neovim - uses terminal use "wellle/targets.vim" -- Additional targets for inside and around motions @@ -47,10 +44,9 @@ return require("packer").startup { use "jbyuki/one-small-step-for-vimkind" -- Debugger for Nvim-Lua -- Snippets - if vim.g.loaded_python3_provider ~= 0 then - use "SirVer/ultisnips" -- Snippets in python format - use "honza/vim-snippets" -- Collection of snippets for UltiSnips - end + use "L3MON4D3/LuaSnip" -- snippets support + use "rafamadriz/friendly-snippets" -- Collection of snippets + use "saadparwaiz1/cmp_luasnip" -- cmp snippets support -- Language support use "tpope/vim-rails" -- Enables all rails command through vim and integrates with projectionist @@ -69,10 +65,7 @@ return require("packer").startup { use "cdelledonne/vim-cmake" -- CMake integration -- Treesitter - use { - "nvim-treesitter/nvim-treesitter", - run = ":TSUpdate" - } -- Treesitter integration + use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"} -- Treesitter integration use "nvim-treesitter/playground" -- TSPlaygroundToggle - access treesitter data -- LSP @@ -82,7 +75,6 @@ return require("packer").startup { use "hrsh7th/cmp-buffer" -- Buffer source for nvim-cmp use "hrsh7th/cmp-path" -- Path source for nvim-cmp use "hrsh7th/cmp-nvim-lua" -- Nvim-Lua source for nvim-cmp - use "quangnguyen30192/cmp-nvim-ultisnips" -- Ultisnips source for nvim-cmp use "hrsh7th/nvim-cmp" -- completion integration use "nvim-lua/lsp_extensions.nvim" -- LSP extensions (like closing labels for Dart) use "jose-elias-alvarez/null-ls.nvim" -- Linting and formatting diff --git a/symlinks/config/nvim/lua/lsp/completion.lua b/symlinks/config/nvim/lua/lsp/completion.lua index 29b6094..41fefcf 100644 --- a/symlinks/config/nvim/lua/lsp/completion.lua +++ b/symlinks/config/nvim/lua/lsp/completion.lua @@ -1,16 +1,15 @@ ------------------------------------------------------------------------------- -- - LSP completion config - ------------------------------------------------------------------------------- - -- Set completeopt to have a better completion experience vim.o.completeopt = "menu,menuone,noselect" local cmp = require "cmp" +local luasnip = require("luasnip") + cmp.setup { snippet = { - expand = function(args) - vim.fn["UltiSnips#Anon"](args.body) - end + expand = function(args) require'luasnip'.lsp_expand(args.body) end }, mapping = { [""] = cmp.mapping.scroll_docs(-4), @@ -31,13 +30,24 @@ cmp.setup { else fallback() end - end + end, + [""] = cmp.mapping(function(fallback) + if luasnip.jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, {"i", "s"}), + [""] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, {"i", "s"}) }, sources = { - {name = "nvim_lsp"}, - {name = "nvim_lua"}, - {name = "path"}, - {name = "ultisnips"}, - {name = "buffer"} + {name = "nvim_lsp"}, {name = "nvim_lua"}, {name = "path"}, + {name = "luasnip"}, {name = "buffer"} } } diff --git a/symlinks/config/nvim/plugin/snippets.lua b/symlinks/config/nvim/plugin/snippets.lua new file mode 100644 index 0000000..8c8c8b0 --- /dev/null +++ b/symlinks/config/nvim/plugin/snippets.lua @@ -0,0 +1,11 @@ +local luasnip = require("luasnip") +local s = luasnip.snippet +local f = luasnip.function_node + +luasnip.add_snippets("all", { + s("date", {f(function(_, _) return os.date("%Y-%m-%d") end)}), + s("datetime", {f(function(_, _) return os.date("%Y-%m-%d %H:%M:%S") end)}), + s("diso", {f(function(_, _) return os.date("%Y-%m-%dT%H:%M:%S") end)}) +}) + +require("luasnip.loaders.from_vscode").lazy_load() diff --git a/symlinks/config/nvim/plugin/ultisnips.vim b/symlinks/config/nvim/plugin/ultisnips.vim deleted file mode 100644 index 13c1a1f..0000000 --- a/symlinks/config/nvim/plugin/ultisnips.vim +++ /dev/null @@ -1,6 +0,0 @@ -" ----------------------------------------------------------------------------- -" - UltiSnips configuration - -" ----------------------------------------------------------------------------- - -" Force ultisnips to use vim directory (for supporting both NeoVim and Vim) -let g:UltiSnipsSnippetDirectories=[$OVIMHOME."/UltiSnips"]