Update used snippets

pull/2/head
Ensar Sarajčić 2022-04-27 23:43:49 +02:00
parent 58f395081f
commit 6d7ed000ee
4 changed files with 36 additions and 29 deletions

View File

@ -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

View File

@ -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 = {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
@ -31,13 +30,24 @@ cmp.setup {
else
fallback()
end
end
end,
["<C-j>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, {"i", "s"}),
["<C-k>"] = 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"}
}
}

View File

@ -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()

View File

@ -1,6 +0,0 @@
" -----------------------------------------------------------------------------
" - UltiSnips configuration -
" -----------------------------------------------------------------------------
" Force ultisnips to use vim directory (for supporting both NeoVim and Vim)
let g:UltiSnipsSnippetDirectories=[$OVIMHOME."/UltiSnips"]