diff --git a/Makefile b/Makefile index 571ad38..a1d1b4b 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,15 @@ workspace := $(HOME) .PHONY: all +# NIX +$(workspace)/.config/nixpkgs: + mkdir -p $@ + +nix/%: $(workspace)/.config/nixpkgs + ln -fs $(dotfiles)/$@ $Dsurround', { noremap = true }) + vim.api.nvim_set_keymap('n', 'cs', 'Csurround', { noremap = true }) + vim.api.nvim_set_keymap('n', 'ys', 'Ysurround', { noremap = true }) + vim.api.nvim_set_keymap('n', 'yS', 'YSurround', { noremap = true }) + vim.api.nvim_set_keymap('n', 'yss', 'Yssurround', { noremap = true }) + vim.api.nvim_set_keymap('n', 'ySS', 'YSsurround', { noremap = true }) + vim.api.nvim_set_keymap('x', 'Y', 'VSurround', { noremap = true }) + vim.api.nvim_set_keymap('x', 'gY', 'VgSurround', { noremap = true }) + vim.api.nvim_set_keymap('i', '', '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 {{{ @@ -323,7 +357,12 @@ require'packer'.startup {function (use) } vim.api.nvim_set_keymap('n', '[telescope]', '', { noremap = true }) vim.api.nvim_set_keymap('n', '', '[telescope]', {}) - vim.api.nvim_set_keymap('n', '[telescope]/', 'Telescope find_files theme=get_ivy', { noremap = true }) + vim.api.nvim_set_keymap( + 'n', + '[telescope]/', + "lua require'telescope.builtin'.find_files(require'telescope.themes'.get_ivy({no_ignore=false}))", + { noremap = true } + ) vim.api.nvim_set_keymap('n', '[telescope]f', 'Telescope live_grep theme=get_ivy', { noremap = true }) vim.api.nvim_set_keymap('n', '[telescope]y', 'Telescope registers theme=get_ivy', { noremap = true }) vim.api.nvim_set_keymap('n', '[telescope]b', 'Telescope buffers theme=get_ivy', { noremap = true }) @@ -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 @@ -412,41 +452,47 @@ require'packer'.startup {function (use) }, mapping = { [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif vim.fn["vsnip#available"](1) == 1 then - feedkey("(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 ``. - end + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + elseif has_words_before() then + cmp.complete() + else + fallback() + end end, { "i", "s" } ), [""] = cmp.mapping(function() - if cmp.visible() then - cmp.select_prev_item() - elseif vim.fn["vsnip#jumpable"](-1) == 1 then - feedkey("(vsnip-jump-prev)", "") - end + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn["vsnip#jumpable"](-1) == 1 then + feedkey("(vsnip-jump-prev)", "") + else + fallback() + end end, { "i", "s" } ), [""] = cmp.mapping.confirm { select = true }, + [""] = 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 } ---}}} @@ -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 } @@ -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', @@ -1387,6 +1462,9 @@ vim.cmd [[ "elisp autocmd BufNewFile,BufRead *.elisp set filetype=elisp + "direnv + autocmd BufNewFile,BufRead .envrc set filetype=sh + augroup END ]] ---}}} diff --git a/nvim/vsnip/org.json b/nvim/vsnip/org.json new file mode 100644 index 0000000..35c0840 --- /dev/null +++ b/nvim/vsnip/org.json @@ -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." + } +} diff --git a/nvim/vsnip/tex.json b/nvim/vsnip/tex.json new file mode 100644 index 0000000..b39c164 --- /dev/null +++ b/nvim/vsnip/tex.json @@ -0,0 +1,11 @@ +{ + "block_math": { + "prefix": ["\\["], + "body": [ + "\\[", + "$0", + "\\]" + ], + "description": "block math template." + } +}