diff options
Diffstat (limited to 'nvim/.config')
| -rw-r--r-- | nvim/.config/nvim/init.lua | 21 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/user/keymaps.lua | 28 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/user/lsp/handlers.lua | 2 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/user/luasnip.lua | 43 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/user/options.lua | 2 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/user/plugins.lua | 1 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/user/snippets.lua | 13 |
7 files changed, 96 insertions, 14 deletions
diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index e98fbc5..cd7e329 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,6 +1,5 @@ --[[ vim.g.material_style = "palenight" ]] - require('onedark').setup { style = 'deep', transparent = true, @@ -23,6 +22,8 @@ require "user.plugins" require "user.colorscheme" require "user.cmp" require "user.lsp" +require "user.snippets" +--[[ require "user.luasnip" ]] require "user.telescope" require "user.treesitter" require "user.autopairs" @@ -41,3 +42,21 @@ require "user.autocommands" --require "material" + + + + + + + + + + + + + + + + + + diff --git a/nvim/.config/nvim/lua/user/keymaps.lua b/nvim/.config/nvim/lua/user/keymaps.lua index 1211057..7e25c15 100644 --- a/nvim/.config/nvim/lua/user/keymaps.lua +++ b/nvim/.config/nvim/lua/user/keymaps.lua @@ -1,14 +1,15 @@ local opts = { noremap = true, silent = true } -local term_opts = { silent = true } - -- Shorten function name local keymap = vim.api.nvim_set_keymap +--local ls = require "luasnip" + --Remap space as leader key keymap("", "<Space>", "<Nop>", opts) vim.g.mapleader = " " vim.g.maplocalleader = " " +local ls = require "luasnip" -- Modes -- normal_mode = "n", @@ -65,17 +66,22 @@ keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts) -- Jumping quickly between two files keymap("n", "<leader><leader>", ":bprevious<CR>", opts) --- Compiling code -- --- keymap("n", "<F3>", ":w <CR> :!g++ -fsanitize=address -std=c++17 -Wall -Wextra -Wshadow -DONPC -O2 -o %< % && ./%< <CR>", opts) --- keymap("n", "<F3>", ":w <CR> :!g++ -fsanitize=address -std=c++17 -Wall -Wextra -Wshadow -DONPC -O2 -o %< % <CR>", opts) +--CompetiTest keymap("n", "<F2>", ":CompetiTestReceive<CR>", opts) keymap("n", "<F3>", ":CompetiTestRun<CR>", opts) +--sourcing luasnips +keymap("n", "<leader><leader>s", "<cmd> source ~/.config/nvim/lua/user/luasnip.lua<CR>", opts) + + +-- luasnips +vim.keymap.set({ "i", "s" }, "<c-k>", function () + print("hello") + if ls.expand_or_jumpable then + ls.expand_or_jump()end +end, { silent = false }) +--vim.keymap.set("i", "<c-h>", function () if ls.jumpable(-1) then ls.jump(-1)end end, opts) --- Terminal -- --- Better terminal navigation --- keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts) --- keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts) --- keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts) --- keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts) +--keymap("i", "<c-l>", "function () if ls.expand_or_jumpable then ls.expand_or_jump()end end", opts) +--keymap("i", "<c-h>", "function () if ls.jumpable(-1) then ls.jump(-1)end end", opts) diff --git a/nvim/.config/nvim/lua/user/lsp/handlers.lua b/nvim/.config/nvim/lua/user/lsp/handlers.lua index dda229d..2baf039 100644 --- a/nvim/.config/nvim/lua/user/lsp/handlers.lua +++ b/nvim/.config/nvim/lua/user/lsp/handlers.lua @@ -99,6 +99,6 @@ if not status_ok then return end -M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities) +M.capabilities = cmp_nvim_lsp.default_capabilities(capabilities) return M diff --git a/nvim/.config/nvim/lua/user/luasnip.lua b/nvim/.config/nvim/lua/user/luasnip.lua new file mode 100644 index 0000000..ecde02b --- /dev/null +++ b/nvim/.config/nvim/lua/user/luasnip.lua @@ -0,0 +1,43 @@ +local ls = require "luasnip" + +local snippet = ls.s +local f = ls.function_node +local t = ls.text_node +local i = ls.insert_node + +local shortcut = function(val) + if type(val) == "string" then + return { t { val }, i(0) } + end + + if type(val) == "table" then + for k, v in ipairs(val) do + if type(v) == "string" then + val[k] = t { v } + end + end + end + + return val +end + +local M = {} + +M.same = function(index) + return f(function(args) + return args[1] + end, { index }) +end + +M.make = function(tbl) + local result = {} + for k, v in pairs(tbl) do + table.insert(result, (snippet({ trig = k, desc = v.desc }, shortcut(v)))) + end + + return result +end + + +return M + diff --git a/nvim/.config/nvim/lua/user/options.lua b/nvim/.config/nvim/lua/user/options.lua index 1ad2efa..bf3af7b 100644 --- a/nvim/.config/nvim/lua/user/options.lua +++ b/nvim/.config/nvim/lua/user/options.lua @@ -32,7 +32,7 @@ local options = { wrap = true, -- display lines as one long line scrolloff = 8, -- is one of my fav sidescrolloff = 8, - guifont = "JetBrainsMonoExtraBold Nerd Font:h14", -- the font used in graphical neovim applications + guifont = "JetBrainsMonoExtraBold Nerd Font:h10", -- the font used in graphical neovim applications } vim.opt.shortmess:append "c" diff --git a/nvim/.config/nvim/lua/user/plugins.lua b/nvim/.config/nvim/lua/user/plugins.lua index f646ba5..a147567 100644 --- a/nvim/.config/nvim/lua/user/plugins.lua +++ b/nvim/.config/nvim/lua/user/plugins.lua @@ -95,6 +95,7 @@ return packer.startup(function(use) use "saadparwaiz1/cmp_luasnip" -- snippet completions use "hrsh7th/cmp-nvim-lsp" use "windwp/nvim-ts-autotag" --auto close tags + -- snippets use "L3MON4D3/LuaSnip" --snippet engine use "rafamadriz/friendly-snippets" -- a bunch of snippets to use diff --git a/nvim/.config/nvim/lua/user/snippets.lua b/nvim/.config/nvim/lua/user/snippets.lua new file mode 100644 index 0000000..d94d359 --- /dev/null +++ b/nvim/.config/nvim/lua/user/snippets.lua @@ -0,0 +1,13 @@ +local ls = require "luasnip" + +ls.snippets = { + all = { + ls.parser.parse_snippet("expand", "-- This is what was expanded --"), + }, + lua = { + + } +} + + + |
