summaryrefslogtreecommitdiff
path: root/config/essentials/nvim
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-03-12 18:35:36 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-03-12 18:35:36 +0100
commitdef003a709daac88d91499f50e9d3fd246ee3db2 (patch)
tree6b18eec5e30f300bca47cf3b8bd89cab12627def /config/essentials/nvim
parente1b3f28bb1f8f1f9084ae96aa5ef79d39769049f (diff)
parentfab8d61418e2652881a56b586588f3373df5f971 (diff)
Merge remote-tracking branch 'refs/remotes/origin/main'
Diffstat (limited to 'config/essentials/nvim')
-rw-r--r--config/essentials/nvim/after/plugin/luasnip.lua142
-rw-r--r--config/essentials/nvim/ftplugin/all.lua1
-rw-r--r--config/essentials/nvim/ftplugin/sh.lua1
-rw-r--r--config/essentials/nvim/lua/tlast/cmp/bash.lua1
-rw-r--r--config/essentials/nvim/lua/tlast/cmp/init.lua1
-rw-r--r--config/essentials/nvim/lua/tlast/packer.lua1
-rw-r--r--config/essentials/nvim/lua/tlast/remap.lua95
-rw-r--r--config/essentials/nvim/lua/tlast/set.lua61
8 files changed, 225 insertions, 78 deletions
diff --git a/config/essentials/nvim/after/plugin/luasnip.lua b/config/essentials/nvim/after/plugin/luasnip.lua
new file mode 100644
index 0000000..2e375e1
--- /dev/null
+++ b/config/essentials/nvim/after/plugin/luasnip.lua
@@ -0,0 +1,142 @@
+local ls = require("luasnip")
+local s = ls.snippet
+local sn = ls.snippet_node
+local isn = ls.indent_snippet_node
+local t = ls.text_node
+local i = ls.insert_node
+local f = ls.function_node
+local c = ls.choice_node
+local d = ls.dynamic_node
+local r = ls.restore_node
+local events = require("luasnip.util.events")
+local ai = require("luasnip.nodes.absolute_indexer")
+local extras = require("luasnip.extras")
+local l = extras.lambda
+local rep = extras.rep
+local p = extras.partial
+local m = extras.match
+local n = extras.nonempty
+local dl = extras.dynamic_lambda
+local fmt = require("luasnip.extras.fmt").fmt
+local fmta = require("luasnip.extras.fmt").fmta
+local conds = require("luasnip.extras.expand_conditions")
+local postfix = require("luasnip.extras.postfix").postfix
+local types = require("luasnip.util.types")
+local parse = require("luasnip.util.parser").parse_snippet
+
+-- keymaps
+vim.keymap.set({"i", "s"}, "<C-k>", "<Plug>luasnip-expand-or-jump", { noremap = true })
+vim.keymap.set({"i", "s"}, "<C-j>", "<Plug>luasnip-jump-prev", { noremap = true })
+vim.keymap.set({"i", "s"}, "<C-l>", "<Plug>luasnip-next-choice", { noremap = true })
+vim.keymap.set("n", "<leader><leader>s", function()
+ ls.cleanup()
+ vim.cmd("source ~/.config/nvim/after/plugin/luasnip.lua")
+ print("snippets reloaded.")
+end, { noremap = true })
+
+ls.add_snippets("lua", {
+ -- print
+ s("pt", fmt([[print("{}")]], { i(1, "Hello World!") })),
+ -- local function
+ parse("lf", "local $1 = function($2)\n\t$3\nend$0", {}),
+ -- require
+ s("lrq", fmt("local {} = require('{}')", { i(1), rep(1) })),
+ parse("rq", "require('$1')$0", {}),
+ parse("rqs", "require('$1').setup {\n\t$2\n}$0", {}),
+ parse("use", "use('$1')$0", {}),
+ -- function
+ s("fn", fmt(
+ [[
+ function {}({})
+ {}
+ end{}
+ ]],
+ { i(1), i(2), i(3), i(0) })),
+ parse("sn", "s(\"$1\", fmt(\n[[\n$2\n]],\n{ $3 })),$0", {}),
+})
+
+ls.add_snippets("html", {
+ s("<!DOCTYPE>", {
+ t({"<!DOCTYPE html>", "<html lang=\"en\">", "\t<head>", "\t\t<title>"}),
+ i(1, "title"),
+ t("</title>"), i(2),
+ t({"", "\t</head>", "\t<body>", "\t\t<h1>"}),
+ i(3, "Header"),
+ t("</h1>"), i(4),
+ t({"", "\t</body>", "</html>"}), i(0)
+ }),
+})
+
+ls.add_snippets("java", {
+ -- function
+ s("fn", fmt(
+ [[
+ {}{} {} ({}) {{
+ {}
+ }}
+ ]],
+ {
+ c(1, {t "public ", t "private ", t ""}),
+ i(2, "type"),
+ i(3, "f"),
+ i(4), i(0)
+ })),
+ -- constructor
+ s("cst", fmt(
+ [[
+ public {} ({}) {{
+ {}
+ }}{}
+ ]],
+ { i(1), i(2), i(3), i(0) })),
+ -- setter function
+ s("sfn", fmt(
+ [[
+ {}void set_{} ({} {}) {{
+ this.{} = {};
+ }}{}
+ ]],
+ { c(1, {t "public ", t "private ", t ""}),
+ i(2), i(3), rep(2), rep(2), rep(2), i(0) })),
+ -- getter function
+ s("gfn", fmt(
+ [[
+ {}{} get_{} () {{
+ return this.{};
+ }}{}
+ ]],
+ { c(1, {t "public ", t "private ", t ""}), i(2, "type"), i(3), rep(3), i(0)})),
+ s("psv", fmt(
+ [[
+ public class Main {{
+ public static void main (String[] args) {{
+ {}
+ }}
+ }}
+ ]],
+ { i(0) })),
+ -- constructor
+ s("class", fmt(
+ [[
+ {}class {} {{
+ {}
+ }}
+ ]],
+ { c(1, {t "public ", t "private ", t ""}), i(2), i(0)})),
+ -- print
+ parse("pt", "System.out.println($1);$0", {}),
+ parse("pti", "System.out.println(\"$1: \" + $1);$0", {}),
+ parse("abs", "Math.abs($1);$0", {}),
+ -- quick
+ s("pr", t "private "),
+ s("ob", fmt(
+ [[
+ {} {} = new {}({});
+ {}
+ ]],
+ { i(1), i(2), rep(1), i(3), i(0) })),
+})
+
+ls.add_snippets("sh", {
+ parse("fn", "function $1 {\n\t$2\n}$0", {})
+})
diff --git a/config/essentials/nvim/ftplugin/all.lua b/config/essentials/nvim/ftplugin/all.lua
new file mode 100644
index 0000000..1608f4e
--- /dev/null
+++ b/config/essentials/nvim/ftplugin/all.lua
@@ -0,0 +1 @@
+vim.cmd("set formatoptions=cqrnj")
diff --git a/config/essentials/nvim/ftplugin/sh.lua b/config/essentials/nvim/ftplugin/sh.lua
index 3ebb1c9..4b66c75 100644
--- a/config/essentials/nvim/ftplugin/sh.lua
+++ b/config/essentials/nvim/ftplugin/sh.lua
@@ -1,2 +1,3 @@
vim.keymap.set("n", "<LocalLeader>t", "<cmd>s/\\(\\s*\\)\\(.*\\)/\\1echo \"\\2\"<cr><cmd>setlocal nohls<cr>")
vim.keymap.set("n", "<LocalLeader>i", "<cmd>s/\\(\\s*\\)\\(.*\\)/\\1echo \"\\2: ${\\2}\"<cr><cmd>setlocal nohls<cr>")
+vim.opt.formatoptions = "cqrnj"
diff --git a/config/essentials/nvim/lua/tlast/cmp/bash.lua b/config/essentials/nvim/lua/tlast/cmp/bash.lua
new file mode 100644
index 0000000..91b6fba
--- /dev/null
+++ b/config/essentials/nvim/lua/tlast/cmp/bash.lua
@@ -0,0 +1 @@
+require'lspconfig'.bashls.setup{}
diff --git a/config/essentials/nvim/lua/tlast/cmp/init.lua b/config/essentials/nvim/lua/tlast/cmp/init.lua
index d932138..a80856c 100644
--- a/config/essentials/nvim/lua/tlast/cmp/init.lua
+++ b/config/essentials/nvim/lua/tlast/cmp/init.lua
@@ -1,6 +1,7 @@
require("tlast.cmp.setup")
require("tlast.cmp.arduino")
+require("tlast.cmp.bash")
require("tlast.cmp.clangd")
require("tlast.cmp.html")
require("tlast.cmp.css")
diff --git a/config/essentials/nvim/lua/tlast/packer.lua b/config/essentials/nvim/lua/tlast/packer.lua
index 2400ff9..931e7d4 100644
--- a/config/essentials/nvim/lua/tlast/packer.lua
+++ b/config/essentials/nvim/lua/tlast/packer.lua
@@ -6,6 +6,7 @@ return require('packer').startup(function(use)
'nvim-telescope/telescope.nvim', tag = '0.1.1',
requires = { {'nvim-lua/plenary.nvim'} }
}
+ use('nvim-telescope/telescope-symbols.nvim')
use('theprimeagen/harpoon')
-- colors
diff --git a/config/essentials/nvim/lua/tlast/remap.lua b/config/essentials/nvim/lua/tlast/remap.lua
index 09589c4..c2d4c0b 100644
--- a/config/essentials/nvim/lua/tlast/remap.lua
+++ b/config/essentials/nvim/lua/tlast/remap.lua
@@ -1,48 +1,43 @@
vim.g.mapleader = " "
-vim.g.localleader = "\\"
+vim.g.maplocalleader = "\\"
-vim.keymap.set("n", "-", vim.cmd.Ex)
+-- -- vinegar is already doing this
+-- vim.keymap.set("n", "-", vim.cmd.Ex)
-- moving
-vim.keymap.set("i", "<C-a>", "<C-o>I")
-vim.keymap.set("i", "<C-e>", "<C-o>A")
-vim.keymap.set("i", "<C-k>", "<C-o>D")
-
--- -- add closing
-vim.keymap.set("i", '"', '""<Left>')
--- vim.keymap.set("i", "'", "''<Left>")
--- vim.keymap.set("i", "(", "()<Left>")
--- vim.keymap.set("i", "[", "[]<Left>")
--- vim.keymap.set("i", "{", "{}<Left>")
-vim.keymap.set("i", "{<cr>", "{<cr>}<C-o>O")
-vim.keymap.set("i", "{;<cr>", "{<cr>};<C-o>O")
+vim.keymap.set("i", "<C-a>", "<C-o>I", { noremap = true })
+vim.keymap.set("i", "<C-e>", "<C-o>A", { noremap = true })
+vim.keymap.set("i", "<C-k>", "<C-o>D", { noremap = true })
+
+vim.keymap.set("i", "{<cr>", "{<cr>}<C-o>O", { noremap = true })
+vim.keymap.set("i", "{;<cr>", "{<cr>};<C-o>O", { noremap = true })
-- buffers
-vim.keymap.set("n", "gb", "<cmd>buffers<cr>:buffer<Space>")
-vim.keymap.set("n", "<Leader>q", "<cmd>q!<cr>")
-vim.keymap.set("n", "<Leader>Q", "<cmd>qa!<cr>")
+vim.keymap.set("n", "gb", "<cmd>buffers<cr>:buffer<Space>", { noremap = true })
+vim.keymap.set("n", "<Leader>q", "<cmd>q!<cr>", { noremap = true })
+vim.keymap.set("n", "<Leader>Q", "<cmd>qa!<cr>", { noremap = true })
-- Windows
-vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-h>", "<C-W>h")
-vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-j>", "<C-W>j")
-vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-k>", "<C-W>k")
-vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-l>", "<C-W>l")
-vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-o>", "<C-W>o")
+vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-h>", "<C-W>h", { noremap = true })
+vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-j>", "<C-W>j", { noremap = true })
+vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-k>", "<C-W>k", { noremap = true })
+vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-l>", "<C-W>l", { noremap = true })
+vim.keymap.set({"n", "i", "v", "c", "o", "s", "x"}, "<A-o>", "<C-W>o", { noremap = true })
-- command line
-vim.keymap.set("c", "<M-b>", "<C-Left>")
-vim.keymap.set("c", "<M-f>", "<C-Right>")
-vim.keymap.set("c", "<M-d>", "<C-Right><C-w>")
+vim.keymap.set("c", "<M-b>", "<C-Left>", { noremap = true })
+vim.keymap.set("c", "<M-f>", "<C-Right>", { noremap = true })
+vim.keymap.set("c", "<M-d>", "<C-Right><C-w>", { noremap = true })
-- move visual selection up/down wards
-vim.keymap.set("v", "J", "<cmd>m '>+1<cr>gv=gv<cr>")
-vim.keymap.set("v", "K", "<cmd>m '<-2<cr>gv=gv<cr>")
+vim.keymap.set("v", "J", "<cmd>m '>+1<cr>gv=gv<cr>", { noremap = true })
+vim.keymap.set("v", "K", "<cmd>m '<-2<cr>gv=gv<cr>", { noremap = true })
-- clipboard
-vim.keymap.set("n", "<Leader>y", "\"+y")
-vim.keymap.set("n", "<Leader>o", "<Plug>OSCYank")
+vim.keymap.set("n", "<Leader>y", "\"+y", { noremap = true })
+vim.keymap.set("n", "<Leader>o", "<Plug>OSCYank", { noremap = true })
-- templates
-vim.keymap.set("n", "<Leader>rt", ":r " .. vim.fn.stdpath("config") .. "/templates/")
+vim.keymap.set("n", "<LocalLeader>rt", ":-1r " .. vim.fn.stdpath("config") .. "/templates", { noremap = true })
-- hide all
local s = {hidden_all = 0}
@@ -56,41 +51,41 @@ vim.keymap.set("n", "<C-h>", function ()
vim.opt.showcmd = opt
vim.opt.laststatus = opt and 2 or 0
vim.opt.signcolumn = opt and "yes" or "no"
-end)
+end, { noremap = true })
-- utils
-vim.keymap.set("i", "<LocalLeader>r", "<cmd>r!echo -n $RANDOM<cr><esc>kJA")
+vim.keymap.set("i", "<LocalLeader>r", "<cmd>r!echo -n $RANDOM<cr><esc>kJA", { noremap = true })
-- ordered list
-vim.keymap.set("v", "<Leader>n", "I0. <esc>gvg<C-a>")
-vim.keymap.set("v", "<Leader>u", "<cmd>'<,'>s/^[0-9]\\+\\. //<cr><esc>")
+vim.keymap.set("v", "<Leader>n", "I0. <esc>gvg<C-a>", { noremap = true })
+vim.keymap.set("v", "<Leader>u", "<cmd>'<,'>s/^[0-9]\\+\\. //<cr><esc>", { noremap = true })
-- scripts
-vim.keymap.set("n", "<Leader>x", "<cmd>!chmod +x %<cr>", { silent = true})
+vim.keymap.set("n", "<Leader>x", "<cmd>!chmod +x %<cr>", { noremap = true, silent = true})
-- replace
-vim.keymap.set("n", "<Leader>rf", [[:%s/\<<C-r><C-w>\>/<C-r><C-w><C-w>/gI<Left><Left><Left>]])
-vim.keymap.set("n", "<Leader>rl", [[:s/\<<C-r><C-w>\>/<C-r><C-w><C-w>/gI<Left><Left><Left>]])
+vim.keymap.set("n", "<Leader>sf", [[:%s/\<<C-r><C-w>\>/<C-r><C-w><C-w>/gI<Left><Left><Left>]])
+vim.keymap.set("n", "<Leader>sl", [[:s/\<<C-r><C-w>\>/<C-r><C-w><C-w>/gI<Left><Left><Left>]])
-- write
-vim.keymap.set("n", "<LocalLeader>w", "<cmd>write<cr>")
-vim.keymap.set("n", "<LocalLeader>W", "<cmd>write!<cr>")
-vim.keymap.set("n", "<LocalLeader>e", "<cmd>edit<cr>")
-vim.keymap.set("n", "<Leader><M-s>", "<cmd>source<cr>")
+vim.keymap.set("n", "<LocalLeader>w", "<cmd>write<cr>", { noremap = true })
+vim.keymap.set("n", "<LocalLeader>W", "<cmd>write!<cr>", { noremap = true })
+vim.keymap.set("n", "<LocalLeader>e", "<cmd>edit<cr>", { noremap = true })
+vim.keymap.set("n", "<LocalLeader>s", function ()
+ vim.cmd.source()
+ print("sourced.")
+end, { noremap = true })
-- Packer
-vim.keymap.set("n", "<Leader>P", "<cmd>PackerSync<cr>")
+vim.keymap.set("n", "<Leader>P", "<cmd>PackerSync<cr>", { noremap = true })
-- spelling
-vim.keymap.set("n", "<Leader><C-s>", "<cmd>setlocal spell!<cr>")
+vim.keymap.set("n", "<Leader><C-s>", "<cmd>setlocal spell!<cr>", { noremap = true })
-- open terminal in file's parent director
-- this needs to be asynchrous
vim.keymap.set("n", "<Return>", function ()
local cmd = "cd " .. vim.fn.expand("%:p:h") .. "; setsid st"
- vim.fn.jobstart(cmd, {
- on_exit = function(job_id, exit_code, event_type)
- -- Do nothing here
- end
- })
-end)
+ -- asynchrous go brr
+ vim.fn.jobstart(cmd, { on_exit = function(job_id, exit_code, event_type) end })
+end, { noremap = true })
-- clear registers
@@ -103,4 +98,4 @@ vim.keymap.set("n", "<Leader>rc", function ()
for _, r in ipairs(regs) do
vim.fn.setreg(r, {})
end
-end)
+end, { noremap = true })
diff --git a/config/essentials/nvim/lua/tlast/set.lua b/config/essentials/nvim/lua/tlast/set.lua
index a89e2e3..69ee4ae 100644
--- a/config/essentials/nvim/lua/tlast/set.lua
+++ b/config/essentials/nvim/lua/tlast/set.lua
@@ -1,38 +1,43 @@
-vim.opt.clipboard = "unnamed"
+local opt = vim.opt
-vim.opt.termguicolors = true
+opt.clipboard = "unnamed"
-vim.opt.number = true
-vim.opt.relativenumber = true
-vim.opt.showmatch = true
-vim.opt.matchtime = 0
-vim.opt.showcmd = true
-vim.opt.cursorline = true
-vim.opt.ruler = true
+opt.termguicolors = true
-vim.opt.wildmenu = true
-vim.opt.incsearch = true
-vim.opt.hlsearch = false
+opt.number = true
+opt.relativenumber = true
+opt.showmatch = true
+opt.matchtime = 0
+opt.showcmd = true
+opt.cursorline = true
+opt.ruler = true
-vim.opt.mouse = ""
+opt.path:append("**")
-vim.opt.tabstop = 4
-vim.opt.shiftwidth = 4
-vim.opt.backspace = "indent,eol,start"
+opt.wildmenu = true
+opt.incsearch = true
+opt.hlsearch = false
-vim.opt.signcolumn = "yes"
-vim.opt.updatetime = 100
-vim.opt.laststatus = 2
-vim.opt.history = 200
-vim.opt.encoding = "utf-8"
+opt.mouse = ""
-vim.opt.smartindent = true
-vim.opt.scrolloff = 8
+opt.tabstop = 4
+opt.shiftwidth = 4
+opt.backspace = "indent,eol,start"
-vim.opt.ignorecase = true
-vim.opt.smartcase = true
+opt.signcolumn = "yes"
+opt.updatetime = 100
+opt.laststatus = 2
+opt.history = 200
+opt.encoding = "utf-8"
-vim.opt.swapfile = false
-vim.opt.backup = false
+opt.smartindent = true
+opt.scrolloff = 8
-vim.opt.spelllang = "en_us,nl"
+opt.ignorecase = true
+opt.smartcase = true
+
+opt.swapfile = false
+opt.backup = false
+
+opt.spelllang = "en_us,nl"
+opt.formatoptions = "cqrnj"