Skip to content

Commit

Permalink
improved snippets; adds snippets for block math.
Browse files Browse the repository at this point in the history
  • Loading branch information
gzagatti committed Oct 17, 2022
1 parent ee9de16 commit 002fb17
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 29 deletions.
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ workspace := $(HOME)

.PHONY: all

# NIX
$(workspace)/.config/nixpkgs:
mkdir -p $@

nix/%: $(workspace)/.config/nixpkgs
ln -fs $(dotfiles)/$@ $</$*

nix: $(shell find nix -type f)

# SHELLS
inputrc:
ln -fs $(dotfiles)/shells/inputrc $(workspace)/.inputrc
Expand All @@ -23,8 +32,11 @@ shells: bash zsh tmux
$(workspace)/.config/nvim:
mkdir -p $@

nvim/%: $(workspace)/.config/nvim
ln -fs $(dotfiles)/$@ $</$*
$(workspace)/.config/nvim/vsnip: $(workspace)/.config/nvim
mkdir -p $@

nvim/%: $(workspace)/.config/nvim/vsnip
ln -fs $(dotfiles)/$@ $(workspace)/.config/$@

nvim: $(shell find nvim -type f)

Expand Down Expand Up @@ -105,7 +117,12 @@ texlive:
vim:
ln -fs $(dotfiles)/singles/vimrc $(workspace)/.vimrc


zathura:
mkdir -p $(workspace)/.config/zathura
ln -fs $(dotfiles)/singles/zathurarc $(workspace)/.config/zathura/zathurarc

gtk:
mkdir -p $(workspace)/.config/gtk-3.0
mkdir -p $(workspace)/.config/gtk-4.0
ln -fs $(dotfiles)/singles/gtk.css $(workspace)/.config/gtk-3.0/gtk.css
ln -fs $(dotfiles)/singles/gtk.css $(workspace)/.config/gtk-4.0/gtk.css
130 changes: 104 additions & 26 deletions nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ require'packer'.startup {function (use)
}
---}}}

---leap {{{
use {
'ggandor/leap.nvim',
require = { 'tpope/vim-repeat' },
config = function()
require'leap'.add_default_mappings()
vim.keymap.del({'x', 'o'}, 'x')
vim.keymap.del({'x', 'o'}, 'X')
end
}
---}}}

---slime {{{
-- multiplexer integration
use {
Expand Down Expand Up @@ -230,7 +242,29 @@ require'packer'.startup {function (use)

---surround {{{
-- surround text with pairs of elements
use { 'tpope/vim-surround' }
use {
'tpope/vim-surround',
require = { 'tpope/vim-repeat' },
config = function()
vim.g.surround_no_mappings = 0
vim.api.nvim_set_keymap('n', 'ds', '<Plug>Dsurround', { noremap = true })
vim.api.nvim_set_keymap('n', 'cs', '<Plug>Csurround', { noremap = true })
vim.api.nvim_set_keymap('n', 'ys', '<Plug>Ysurround', { noremap = true })
vim.api.nvim_set_keymap('n', 'yS', '<Plug>YSurround', { noremap = true })
vim.api.nvim_set_keymap('n', 'yss', '<Plug>Yssurround', { noremap = true })
vim.api.nvim_set_keymap('n', 'ySS', '<Plug>YSsurround', { noremap = true })
vim.api.nvim_set_keymap('x', 'Y', '<Plug>VSurround', { noremap = true })
vim.api.nvim_set_keymap('x', 'gY', '<Plug>VgSurround', { noremap = true })
vim.api.nvim_set_keymap('i', '<c-s>', '<Plug>Isurround', { noremap = true })
-- surrounds text with escaped delimiters `\` (char 92), e.g. foo -> \( foo \)
-- prompts for delimiter with `\1delimiter: \1`
-- replaces first character `\r^.\r\\\\&` and removes second character `\r.$\r`
-- removes first character `\r^.\r` and replaces second character `\r.$\r\\\\&`
-- see manual for more details :help surround-customizing
vim.g.surround_92 = "\1delimiter: \r^.\r\\\\&\r.$\r\1 \r \1\r^.\r\r.$\r\\\\&\1"
end

}
---}}}

---matchit {{{
Expand Down Expand Up @@ -323,7 +357,12 @@ require'packer'.startup {function (use)
}
vim.api.nvim_set_keymap('n', '[telescope]', '', { noremap = true })
vim.api.nvim_set_keymap('n', '<space>', '[telescope]', {})
vim.api.nvim_set_keymap('n', '[telescope]/', '<cmd>Telescope find_files theme=get_ivy<cr>', { noremap = true })
vim.api.nvim_set_keymap(
'n',
'[telescope]/',
"<cmd>lua require'telescope.builtin'.find_files(require'telescope.themes'.get_ivy({no_ignore=false}))<cr>",
{ noremap = true }
)
vim.api.nvim_set_keymap('n', '[telescope]f', '<cmd>Telescope live_grep theme=get_ivy<cr>', { noremap = true })
vim.api.nvim_set_keymap('n', '[telescope]y', '<cmd>Telescope registers theme=get_ivy<cr>', { noremap = true })
vim.api.nvim_set_keymap('n', '[telescope]b', '<cmd>Telescope buffers theme=get_ivy<cr>', { noremap = true })
Expand Down Expand Up @@ -380,17 +419,18 @@ require'packer'.startup {function (use)
'hrsh7th/nvim-cmp',
requires = {
'hrsh7th/cmp-nvim-lsp',
-- 'hrsh7th/cmp-buffer',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'hrsh7th/vim-vsnip',
'hrsh7th/cmp-vsnip',
'kdheepak/cmp-latex-symbols',
'gzagatti/cmp-latex-symbols',
'hrsh7th/cmp-nvim-lua',
'ray-x/cmp-treesitter',
},
config = function ()

vim.g.vsnip_snippet_dir = vim.env.XDG_CONFIG_HOME.."/nvim/vsnip"

local cmp = require('cmp')

-- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings
Expand All @@ -412,41 +452,47 @@ require'packer'.startup {function (use)
},
mapping = {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
{ "i", "s" }
),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
else
fallback()
end
end,
{ "i", "s" }
),
["<CR>"] = cmp.mapping.confirm { select = true },
["<C-Space>"] = cmp.mapping.complete(),
},
sources = {
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = 'latex_symbols' },
-- { name = 'buffer' },
{ name = 'path' },
{ name = 'orgmode' },
{ name = 'nvim_lua' },
{ name = 'treesitter' },
{ name = 'neorg' },
},
-- override trigger characters, so they don't interfere with snippets
{ name = 'orgmode', trigger_characters = {} },
{ name = 'latex_symbols' },
{ name = 'buffer', keyword_length = 3 },
}, {
}),
}


end
}
---}}}
Expand Down Expand Up @@ -634,7 +680,7 @@ require'packer'.startup {function (use)
local lspconfig = require'lspconfig'

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
capabilities = require("cmp_nvim_lsp").default_capabilities()

local opts = { noremap=true, silent=true }

Expand Down Expand Up @@ -965,6 +1011,35 @@ require'packer'.startup {function (use)
-- }
--}}}

---neorg {{{
use {
'nvim-neorg/neorg',
requires = { 'nvim-lua/plenary.nvim', 'nvim-treesitter/nvim-treesitter' },
config = function()
require('neorg').setup{
load = {
["core.defaults"] = {},
["core.norg.dirman"] = {
config = {
workspaces = {
norg = "~/norg",
},
index = "inbox.norg",
autochdir = true,
}
},
["core.gtd.base"] = {
config = {
workspace = "norg",
},
},
["core.norg.qol.toc"] = {},
}
}
end,
}
---}}}

---theme: dracula {{{
use {
'dracula/vim',
Expand Down Expand Up @@ -1387,6 +1462,9 @@ vim.cmd [[
"elisp
autocmd BufNewFile,BufRead *.elisp set filetype=elisp
"direnv
autocmd BufNewFile,BufRead .envrc set filetype=sh
augroup END
]]
---}}}
Expand Down
20 changes: 20 additions & 0 deletions nvim/vsnip/org.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"begin_src": {
"prefix": ["beg", "#+beg"],
"body": [
"#+begin_src${1}",
"$0",
"#+end_src"
],
"description": "#+begin_src template."
},
"block_math": {
"prefix": ["\\["],
"body": [
"\\[",
"$0",
"\\]"
],
"description": "block math template."
}
}
11 changes: 11 additions & 0 deletions nvim/vsnip/tex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"block_math": {
"prefix": ["\\["],
"body": [
"\\[",
"$0",
"\\]"
],
"description": "block math template."
}
}

0 comments on commit 002fb17

Please sign in to comment.