refactor(nvim): cleanup nvim config
This commit is contained in:
@@ -87,7 +87,6 @@ local servers = {
|
||||
},
|
||||
openscad_ls = {},
|
||||
pyright = {},
|
||||
-- tsserver = {},
|
||||
svelte = {
|
||||
plugin = {
|
||||
svelte = {
|
||||
@@ -96,7 +95,6 @@ local servers = {
|
||||
},
|
||||
},
|
||||
tailwindcss = {},
|
||||
-- vtsls = {},
|
||||
ts_ls = {},
|
||||
-- vtsls = {
|
||||
-- maxTsServerMemory = 16384,
|
||||
|
||||
@@ -1,23 +1,5 @@
|
||||
local ls = require("luasnip")
|
||||
|
||||
local s = ls.snippet
|
||||
local sn = ls.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 l = require("luasnip.extras").lambda
|
||||
local rep = require("luasnip.extras").rep
|
||||
local p = require("luasnip.extras").partial
|
||||
local m = require("luasnip.extras").match
|
||||
local n = require("luasnip.extras").nonempty
|
||||
local dl = require("luasnip.extras").dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local conds = require("luasnip.extras.expand_conditions")
|
||||
|
||||
ls.config.set_config({
|
||||
history = true,
|
||||
update_events = "TextChanged,TextChangedI",
|
||||
@@ -27,287 +9,5 @@ ls.config.set_config({
|
||||
store_selection_keys = "<Tab>",
|
||||
})
|
||||
|
||||
local function copy(args)
|
||||
return args[1]
|
||||
end
|
||||
|
||||
local function bash(_, _, command)
|
||||
local file = io.popen(command, "r")
|
||||
local res = {}
|
||||
if file then
|
||||
for line in file:lines() do
|
||||
table.insert(res, line)
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
local date_input = function(args, snip, old_state, date_format)
|
||||
print(args, snip, old_state)
|
||||
return sn(nil, i(1, os.date(date_format or "%Y-%m-%d")))
|
||||
end
|
||||
|
||||
-- -- FIXME: EXAMPLE
|
||||
-- ls.add_snippets("all", {
|
||||
-- -- arg1: trigger `fn`,
|
||||
-- -- arg2: nodes to insert into buffer on expansion.
|
||||
-- s("fn", {
|
||||
-- t("//Parameters: "), -- Text.
|
||||
-- f(copy, 2), -- 1: function, 2: placeholders to copy text from
|
||||
-- t({ "", "function " }), -- placeholder/insert.
|
||||
-- i(1),
|
||||
-- t("("), -- placeholder with initial text.
|
||||
-- i(2, "int foo"), -- linebreak
|
||||
-- t({ ") {", "\t" }), -- last placeholder, snippet exit point
|
||||
-- i(0),
|
||||
-- t({ "", "}" }),
|
||||
-- }),
|
||||
-- s("class", {
|
||||
-- -- Choice: Switch between two different Nodes, first parameter is its position, second a list of nodes.
|
||||
-- c(1, {
|
||||
-- t("public "),
|
||||
-- t("private "),
|
||||
-- }),
|
||||
-- t("class "),
|
||||
-- i(2),
|
||||
-- t(" "),
|
||||
-- c(3, {
|
||||
-- t("{"),
|
||||
-- -- sn: Nested Snippet. Instead of a trigger, it has a position, just like insert-nodes. !!! These don't expect a 0-node!!!!
|
||||
-- -- Inside Choices, Nodes don't need a position as the choice node is the one being jumped to.
|
||||
-- sn(nil, {
|
||||
-- t("extends "),
|
||||
-- -- restoreNode: stores and restores nodes.
|
||||
-- -- pass position, store-key and nodes.
|
||||
-- r(1, "other_class", i(1)),
|
||||
-- t(" {"),
|
||||
-- }),
|
||||
-- sn(nil, {
|
||||
-- t("implements "),
|
||||
-- -- no need to define the nodes for a given key a second time.
|
||||
-- r(1, "other_class"),
|
||||
-- t(" {"),
|
||||
-- }),
|
||||
-- }),
|
||||
-- t({ "", "\t" }),
|
||||
-- i(0),
|
||||
-- t({ "", "}" }),
|
||||
-- }),
|
||||
-- -- Alternative printf-like notation for defining snippets. It uses format
|
||||
-- -- string with placeholders similar to the ones used with Python's .format().
|
||||
-- s(
|
||||
-- "fmt1",
|
||||
-- fmt("To {title} {} {}.", {
|
||||
-- i(2, "Name"),
|
||||
-- i(3, "Surname"),
|
||||
-- title = c(1, { t("Mr."), t("Ms.") }),
|
||||
-- })
|
||||
-- ),
|
||||
-- -- To escape delimiters use double them, e.g. `{}` -> `{{}}`.
|
||||
-- -- Multi-line format strings by default have empty first/last line removed.
|
||||
-- -- Indent common to all lines is also removed. Use the third `opts` argument
|
||||
-- -- to control this behaviour.
|
||||
-- s(
|
||||
-- "fmt2",
|
||||
-- fmt(
|
||||
-- [[
|
||||
-- foo({1}, {3}) {{
|
||||
-- return {2} * {4}
|
||||
-- }}
|
||||
-- ]],
|
||||
-- {
|
||||
-- i(1, "x"),
|
||||
-- rep(1),
|
||||
-- i(2, "y"),
|
||||
-- rep(2),
|
||||
-- }
|
||||
-- )
|
||||
-- ),
|
||||
-- -- Empty placeholders are numbered automatically starting from 1 or the last
|
||||
-- -- value of a numbered placeholder. Named placeholders do not affect numbering.
|
||||
-- s(
|
||||
-- "fmt3",
|
||||
-- fmt("{} {a} {} {1} {}", {
|
||||
-- t("1"),
|
||||
-- t("2"),
|
||||
-- a = t("A"),
|
||||
-- })
|
||||
-- ),
|
||||
-- -- The delimiters can be changed from the default `{}` to something else.
|
||||
-- s("fmt4", fmt("foo() { return []; }", i(1, "x"), { delimiters = "[]" })),
|
||||
-- -- `fmta` is a convenient wrapper that uses `<>` instead of `{}`.
|
||||
-- s("fmt5", fmta("foo() { return <>; }", i(1, "x"))),
|
||||
-- -- By default all args must be used. Use strict=false to disable the check
|
||||
-- s(
|
||||
-- "fmt6",
|
||||
-- fmt("use {} only", { t("this"), t("not this") }, { strict = false })
|
||||
-- ),
|
||||
-- -- Use a dynamic_node to interpolate the output of a
|
||||
-- -- function (see date_input above) into the initial
|
||||
-- -- value of an insert_node.
|
||||
-- s("novel", {
|
||||
-- t("It was a dark and stormy night on "),
|
||||
-- d(1, date_input, {}, { user_args = { "%A, %B %d of %Y" } }),
|
||||
-- t(" and the clocks were striking thirteen."),
|
||||
-- }),
|
||||
-- -- Parsing snippets: First parameter: Snippet-Trigger, Second: Snippet body.
|
||||
-- -- Placeholders are parsed into choices with 1. the placeholder text(as a snippet) and 2. an empty string.
|
||||
-- -- This means they are not SELECTed like in other editors/Snippet engines.
|
||||
-- ls.parser.parse_snippet(
|
||||
-- "lspsyn",
|
||||
-- "Wow! This ${1:Stuff} really ${2:works. ${3:Well, a bit.}}"
|
||||
-- ),
|
||||
|
||||
-- -- When wordTrig is set to false, snippets may also expand inside other words.
|
||||
-- ls.parser.parse_snippet(
|
||||
-- { trig = "te", wordTrig = false },
|
||||
-- "${1:cond} ? ${2:true} : ${3:false}"
|
||||
-- ),
|
||||
|
||||
-- -- When regTrig is set, trig is treated like a pattern, this snippet will expand after any number.
|
||||
-- ls.parser.parse_snippet({ trig = "%d", regTrig = true }, "A Number!!"),
|
||||
-- -- Using the condition, it's possible to allow expansion only in specific cases.
|
||||
-- s("cond", {
|
||||
-- t("will only expand in c-style comments"),
|
||||
-- }, {
|
||||
-- condition = function(line_to_cursor, matched_trigger, captures)
|
||||
-- -- optional whitespace followed by //
|
||||
-- return line_to_cursor:match("%s*//")
|
||||
-- end,
|
||||
-- }),
|
||||
-- -- there's some built-in conditions in "luasnip.extras.expand_conditions".
|
||||
-- s("cond2", {
|
||||
-- t("will only expand at the beginning of the line"),
|
||||
-- }, {
|
||||
-- condition = conds.line_begin,
|
||||
-- }),
|
||||
-- -- The last entry of args passed to the user-function is the surrounding snippet.
|
||||
-- s(
|
||||
-- { trig = "a%d", regTrig = true },
|
||||
-- f(function(_, snip)
|
||||
-- return "Triggered with " .. snip.trigger .. "."
|
||||
-- end, {})
|
||||
-- ),
|
||||
-- -- It's possible to use capture-groups inside regex-triggers.
|
||||
-- s(
|
||||
-- { trig = "b(%d)", regTrig = true },
|
||||
-- f(function(_, snip)
|
||||
-- return "Captured Text: " .. snip.captures[1] .. "."
|
||||
-- end, {})
|
||||
-- ),
|
||||
-- s({ trig = "c(%d+)", regTrig = true }, {
|
||||
-- t("will only expand for even numbers"),
|
||||
-- }, {
|
||||
-- condition = function(line_to_cursor, matched_trigger, captures)
|
||||
-- return tonumber(captures[1]) % 2 == 0
|
||||
-- end,
|
||||
-- }),
|
||||
-- -- Use a function to execute any shell command and print its text.
|
||||
-- s("bash", f(bash, {}, "ls")),
|
||||
-- -- Short version for applying String transformations using function nodes.
|
||||
-- s("transform", {
|
||||
-- i(1, "initial text"),
|
||||
-- t({ "", "" }),
|
||||
-- -- lambda nodes accept an l._1,2,3,4,5, which in turn accept any string transformations.
|
||||
-- -- This list will be applied in order to the first node given in the second argument.
|
||||
-- l(l._1:match("[^i]*$"):gsub("i", "o"):gsub(" ", "_"):upper(), 1),
|
||||
-- }),
|
||||
|
||||
-- s("transform2", {
|
||||
-- i(1, "initial text"),
|
||||
-- t("::"),
|
||||
-- i(2, "replacement for e"),
|
||||
-- t({ "", "" }),
|
||||
-- -- Lambdas can also apply transforms USING the text of other nodes:
|
||||
-- l(l._1:gsub("e", l._2), { 1, 2 }),
|
||||
-- }),
|
||||
-- s({ trig = "trafo(%d+)", regTrig = true }, {
|
||||
-- -- env-variables and captures can also be used:
|
||||
-- l(l.CAPTURE1:gsub("1", l.TM_FILENAME), {}),
|
||||
-- }),
|
||||
-- -- Set store_selection_keys = "<Tab>" (for example) in your
|
||||
-- -- luasnip.config.setup() call to populate
|
||||
-- -- TM_SELECTED_TEXT/SELECT_RAW/SELECT_DEDENT.
|
||||
-- -- In this case: select a URL, hit Tab, then expand this snippet.
|
||||
-- s("link_url", {
|
||||
-- t('<a href="'),
|
||||
-- f(function(_, snip)
|
||||
-- -- TM_SELECTED_TEXT is a table to account for multiline-selections.
|
||||
-- -- In this case only the first line is inserted.
|
||||
-- return snip.env.TM_SELECTED_TEXT[1] or {}
|
||||
-- end, {}),
|
||||
-- t('">'),
|
||||
-- i(1),
|
||||
-- t("</a>"),
|
||||
-- i(0),
|
||||
-- }),
|
||||
-- -- Shorthand for repeating the text in a given node.
|
||||
-- s("repeat", { i(1, "text"), t({ "", "" }), rep(1) }),
|
||||
-- -- Directly insert the ouput from a function evaluated at runtime.
|
||||
-- s("part", p(os.date, "%Y")),
|
||||
-- -- use matchNodes (`m(argnode, condition, then, else)`) to insert text
|
||||
-- -- based on a pattern/function/lambda-evaluation.
|
||||
-- -- It's basically a shortcut for simple functionNodes:
|
||||
-- s("mat", {
|
||||
-- i(1, { "sample_text" }),
|
||||
-- t(": "),
|
||||
-- m(1, "%d", "contains a number", "no number :("),
|
||||
-- }),
|
||||
-- -- The `then`-text defaults to the first capture group/the entire
|
||||
-- -- match if there are none.
|
||||
-- s("mat2", {
|
||||
-- i(1, { "sample_text" }),
|
||||
-- t(": "),
|
||||
-- m(1, "[abc][abc][abc]"),
|
||||
-- }),
|
||||
-- -- It is even possible to apply gsubs' or other transformations
|
||||
-- -- before matching.
|
||||
-- s("mat3", {
|
||||
-- i(1, { "sample_text" }),
|
||||
-- t(": "),
|
||||
-- m(
|
||||
-- 1,
|
||||
-- l._1:gsub("[123]", ""):match("%d"),
|
||||
-- "contains a number that isn't 1, 2 or 3!"
|
||||
-- ),
|
||||
-- }),
|
||||
-- -- `match` also accepts a function in place of the condition, which in
|
||||
-- -- turn accepts the usual functionNode-args.
|
||||
-- -- The condition is considered true if the function returns any
|
||||
-- -- non-nil/false-value.
|
||||
-- -- If that value is a string, it is used as the `if`-text if no if is explicitly given.
|
||||
-- s("mat4", {
|
||||
-- i(1, { "sample_text" }),
|
||||
-- t(": "),
|
||||
-- m(1, function(args)
|
||||
-- -- args is a table of multiline-strings (as usual).
|
||||
-- return (#args[1][1] % 2 == 0 and args[1]) or nil
|
||||
-- end),
|
||||
-- }),
|
||||
-- -- The nonempty-node inserts text depending on whether the arg-node is
|
||||
-- -- empty.
|
||||
-- s("nempty", {
|
||||
-- i(1, "sample_text"),
|
||||
-- n(1, "i(1) is not empty!"),
|
||||
-- }),
|
||||
-- -- dynamic lambdas work exactly like regular lambdas, except that they
|
||||
-- -- don't return a textNode, but a dynamicNode containing one insertNode.
|
||||
-- -- This makes it easier to dynamically set preset-text for insertNodes.
|
||||
-- s("dl1", {
|
||||
-- i(1, "sample_text"),
|
||||
-- t({ ":", "" }),
|
||||
-- dl(2, l._1, 1),
|
||||
-- }),
|
||||
-- -- Obviously, it's also possible to apply transformations, just like lambdas.
|
||||
-- s("dl2", {
|
||||
-- i(1, "sample_text"),
|
||||
-- i(2, "sample_text_2"),
|
||||
-- t({ "", "" }),
|
||||
-- dl(3, l._1:gsub("\n", " linebreak ") .. l._2, { 1, 2 }),
|
||||
-- }),
|
||||
-- }, {
|
||||
-- key = "all",
|
||||
-- })
|
||||
|
||||
require("luasnip.loaders.from_lua").lazy_load({ paths = { "~/.config/nvim/snips" } })
|
||||
require("luasnip.loaders.from_vscode").lazy_load({ paths = { "~/.config/Code - Insiders/User/snippets" } })
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
-- require("m_taskwarrior_d").setup()
|
||||
--
|
||||
-- vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, {
|
||||
-- group = vim.api.nvim_create_augroup("TWTask", { clear = true }),
|
||||
-- pattern = "*.md",
|
||||
-- callback = function()
|
||||
-- vim.cmd("TWSyncTasks")
|
||||
-- end,
|
||||
-- })
|
||||
@@ -1,3 +1 @@
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
require("nvim-highlight-colors").setup({})
|
||||
|
||||
@@ -28,9 +28,6 @@ require("lint").linters_by_ft = {
|
||||
yaml = { "yamllint" },
|
||||
}
|
||||
|
||||
-- TODO: Wouldn't it be possible / nice to only try to load the linters when they are
|
||||
-- actually needed?
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
callback = function()
|
||||
require("lint").try_lint()
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
vim.cmd([[
|
||||
" Tidalcycles (sclang and vim-tidal)
|
||||
let g:tidal_default_config = {"socket_name": "default", "target_pane": "tidal:1.1"}
|
||||
let g:tidal_no_mappings = 1
|
||||
vim.g.tidal_default_config = { socket_name = "default", target_pane = "tidal:1.1" }
|
||||
vim.g.tidal_no_mappings = 1
|
||||
|
||||
au FileType tidal nm <buffer> <leader>ep <Plug>TidalParagraphSend
|
||||
au FileType tidal nm <buffer> <leader>ee <Plug>TidalLineSend
|
||||
au FileType tidal nnoremap <buffer> <leader>h :TidalHush<cr>
|
||||
au FileType tidal com! -nargs=1 S :TidalSilence <args>
|
||||
au FileType tidal com! -nargs=1 P :TidalPlay <args>
|
||||
au FileType tidal com! -nargs=0 H :TidalHush
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "tidal",
|
||||
callback = function(e)
|
||||
local buf = e.buf
|
||||
vim.keymap.set("n", "<leader>ep", "<Plug>TidalParagraphSend", { buffer = buf, desc = "Tidal: send paragraph" })
|
||||
vim.keymap.set("n", "<leader>ee", "<Plug>TidalLineSend", { buffer = buf, desc = "Tidal: send line" })
|
||||
vim.keymap.set("n", "<leader>h", ":TidalHush<cr>", { buffer = buf, desc = "Tidal: hush" })
|
||||
vim.api.nvim_buf_create_user_command(buf, "S", "TidalSilence <args>", { nargs = 1 })
|
||||
vim.api.nvim_buf_create_user_command(buf, "P", "TidalPlay <args>", { nargs = 1 })
|
||||
vim.api.nvim_buf_create_user_command(buf, "H", "TidalHush", { nargs = 0 })
|
||||
end,
|
||||
})
|
||||
|
||||
" SuperCollider
|
||||
au BufEnter,BufWinEnter,BufNewFile,BufRead *.sc,*.scd se filetype=supercollider
|
||||
au Filetype supercollider packadd scvim
|
||||
]])
|
||||
-- SuperCollider
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter", "BufNewFile", "BufRead" }, {
|
||||
pattern = { "*.sc", "*.scd" },
|
||||
callback = function()
|
||||
vim.bo.filetype = "supercollider"
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "supercollider",
|
||||
command = "packadd scvim",
|
||||
})
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
local json_newline = function()
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
if line == "" then
|
||||
print("line is empty")
|
||||
return "o"
|
||||
elseif string.byte(line, -1) == string.byte(",") then
|
||||
return "o"
|
||||
elseif string.byte(line, -1) == string.byte("{") then
|
||||
print("line ends with '{'")
|
||||
return "o"
|
||||
elseif string.byte(line, -1) == string.byte("}") then
|
||||
print("line ends with '}'")
|
||||
return "o"
|
||||
else
|
||||
return "A,<CR>"
|
||||
|
||||
@@ -26,5 +26,4 @@ set lcs=trail:·,tab:→\ ,nbsp:␣ " Whitespace rendering
|
||||
set ar " Autoread
|
||||
set spellsuggest+=5 " Limit spell suggestions
|
||||
set wildignore+=*/node_modules/*,*/tmp/*,*.so,*.swp,*.zip
|
||||
" set thesaurus+=./thesaurus/mthesaur.txt " FIXME
|
||||
]])
|
||||
|
||||
@@ -1,60 +1,57 @@
|
||||
vim.cmd([[
|
||||
" Leader keys
|
||||
let mapleader = " "
|
||||
let maplocalleader = ";"
|
||||
|
||||
" Splits & navigation
|
||||
nm s <c-w> " Split horizontal
|
||||
nm ss :sp<CR><c-w>w| " Split horizontal
|
||||
nm sv :vs<CR><c-w>w| " Split vertical
|
||||
nm sw <c-w>w| " Navigate splits
|
||||
nm sh <c-w>h| "
|
||||
nm sj <c-w>j| "
|
||||
nm sk <c-w>k| "
|
||||
nm sl <c-w>l| "
|
||||
nn sH <c-w>8<| " Resize splits
|
||||
nn sJ <c-w>8-| "
|
||||
nn sK <c-w>8+| "
|
||||
nn sL <c-w>8>| "
|
||||
nn s= <c-w>=| " Equalize splits
|
||||
|
||||
" Open
|
||||
nn sb :Lex<cr>| " File tree
|
||||
nn <leader><leader> :noh<cr> |"
|
||||
nn <leader>t :term<cr>| " Open terminal
|
||||
|
||||
" Remaps
|
||||
ino <nowait> jj <esc>| " Normal now
|
||||
nn <left> <nop>| " Hard mode
|
||||
nn <down> <nop>| " "
|
||||
nn <up> <nop>| " "
|
||||
nn <right> <nop>| " "
|
||||
ino <left> <nop>| " "
|
||||
ino <down> <nop>| " "
|
||||
ino <up> <nop>| " "
|
||||
ino <right> <nop>| " "
|
||||
|
||||
" Search
|
||||
nn <c-_> :noh<cr>| " map 'ctrl + /'
|
||||
|
||||
" Line numbers
|
||||
nn <leader>n :set nu! rnu!<cr>
|
||||
|
||||
" Vim configuration
|
||||
nn <leader>ec :vs $MYVIMRC<cr>
|
||||
nn <leader>so :so %<cr>
|
||||
]])
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = ";"
|
||||
|
||||
local set = vim.keymap.set
|
||||
|
||||
set("n", "<leader>cx", "<cmd>!chmod +x %<CR>", { silent = true, desc = "Run `chmod +x` on current file" })
|
||||
set("n", "yp", "<cmd>let @+ = expand('%r')<CR>:p<CR>", { silent = true, desc = "Yank path" })
|
||||
-- splits & navigation
|
||||
set("n", "s", "<c-w>", { desc = "window prefix" })
|
||||
set("n", "ss", ":sp<CR><c-w>w", { desc = "split horizontal" })
|
||||
set("n", "sv", ":vs<CR><c-w>w", { desc = "split vertical" })
|
||||
set("n", "sw", "<c-w>w", { desc = "navigate splits" })
|
||||
set("n", "sh", "<c-w>h", { desc = "focus left split" })
|
||||
set("n", "sj", "<c-w>j", { desc = "focus below split" })
|
||||
set("n", "sk", "<c-w>k", { desc = "focus above split" })
|
||||
set("n", "sl", "<c-w>l", { desc = "focus right split" })
|
||||
set("n", "sH", "<c-w>8<", { desc = "shrink split left" })
|
||||
set("n", "sJ", "<c-w>8-", { desc = "shrink split down" })
|
||||
set("n", "sK", "<c-w>8+", { desc = "grow split up" })
|
||||
set("n", "sL", "<c-w>8>", { desc = "grow split right" })
|
||||
set("n", "s=", "<c-w>=", { desc = "equalize splits" })
|
||||
|
||||
-- Remap native NeoVim comment keymaps
|
||||
set({ "n", "x" }, "<leader>c", "gc", { remap = true, desc = "Toggle comment" })
|
||||
set("n", "<leader>cc", "gcc", { remap = true, desc = "Toggle comment line" })
|
||||
set("o", "<leader>c", "gc", { remap = true, desc = "Comment textobject" })
|
||||
-- open
|
||||
set("n", "sb", ":Lex<cr>", { desc = "file tree" })
|
||||
set("n", "<leader><leader>", ":noh<cr>", { desc = "clear highlights" })
|
||||
set("n", "<leader>t", ":term<cr>", { desc = "open terminal" })
|
||||
|
||||
-- Move lines
|
||||
set("v", "K", ": '<,'>move '<-2<cr>gv")
|
||||
set("v", "J", ": '<,'>move '>+1<cr>gv")
|
||||
-- remaps
|
||||
set("i", "jj", "<esc>", { nowait = true, desc = "exit insert mode" })
|
||||
set("n", "<left>", "<nop>")
|
||||
set("n", "<down>", "<nop>")
|
||||
set("n", "<up>", "<nop>")
|
||||
set("n", "<right>", "<nop>")
|
||||
set("i", "<left>", "<nop>")
|
||||
set("i", "<down>", "<nop>")
|
||||
set("i", "<up>", "<nop>")
|
||||
set("i", "<right>", "<nop>")
|
||||
|
||||
-- search
|
||||
set("n", "<c-_>", ":noh<cr>", { desc = "clear search highlight" })
|
||||
|
||||
-- line numbers
|
||||
set("n", "<leader>n", ":set nu! rnu!<cr>", { desc = "toggle line numbers" })
|
||||
|
||||
-- vim configuration
|
||||
set("n", "<leader>ec", ":vs $MYVIMRC<cr>", { desc = "edit vimrc" })
|
||||
set("n", "<leader>so", ":so %<cr>", { desc = "source current file" })
|
||||
|
||||
set("n", "<leader>cx", "<cmd>!chmod +x %<CR>", { silent = true, desc = "run `chmod +x` on current file" })
|
||||
set("n", "yp", "<cmd>let @+ = expand('%r')<CR>:p<CR>", { silent = true, desc = "yank path" })
|
||||
|
||||
-- remap native NeoVim comment keymaps
|
||||
set({ "n", "x" }, "<leader>c", "gc", { remap = true, desc = "toggle comment" })
|
||||
set("n", "<leader>cc", "gcc", { remap = true, desc = "toggle comment line" })
|
||||
set("o", "<leader>c", "gc", { remap = true, desc = "comment textobject" })
|
||||
|
||||
-- move lines
|
||||
set("v", "K", ": '<,'>move '<-2<cr>gv", { desc = "move selection up" })
|
||||
set("v", "J", ": '<,'>move '>+1<cr>gv", { desc = "move selection down" })
|
||||
|
||||
@@ -17,7 +17,7 @@ local LOCALHOST_IP = "127.0.0.1"
|
||||
|
||||
return {
|
||||
s({ trig = "fn", desc = "Filename" }, { f(TM_FILENAME_BASE) }),
|
||||
s({ trig = "fne", dscr = "Filename (+extension)" }, { f(TM_FILENAME) }),
|
||||
s({ trig = "fne", desc = "Filename (+extension)" }, { f(TM_FILENAME) }),
|
||||
s({ trig = "hm" }, { t(NAME) }),
|
||||
s({ trig = "loho" }, { t(LOCALHOST) }),
|
||||
s({ trig = "lohoi" }, { t(LOCALHOST_IP) }),
|
||||
|
||||
@@ -5,112 +5,112 @@ local i = ls.insert_node
|
||||
|
||||
return {
|
||||
-- Flex
|
||||
s({ trig = "b1", dscr = "Add 'border: 1px <color>;'" }, {
|
||||
s({ trig = "b1", desc = "Add 'border: 1px <color>;'" }, {
|
||||
t("border: 1px solid "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "dfl", dscr = "Add 'display: flex;'" }, {
|
||||
s({ trig = "dfl", desc = "Add 'display: flex;'" }, {
|
||||
t("display: flex;"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "flr", dscr = "Add 'flex-direction: row;'" }, {
|
||||
s({ trig = "flr", desc = "Add 'flex-direction: row;'" }, {
|
||||
t("flex-direction: row;"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "flc", dscr = "Add 'flex-direction: column;'" }, {
|
||||
s({ trig = "flc", desc = "Add 'flex-direction: column;'" }, {
|
||||
t("flex-direction: column;"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "flw", dscr = "Add 'flex-wrap: wrap;'" }, {
|
||||
s({ trig = "flw", desc = "Add 'flex-wrap: wrap;'" }, {
|
||||
t("flex-wrap: wrap;"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "dfc", dscr = "Add 'flex-direction: column;'" }, {
|
||||
s({ trig = "dfc", desc = "Add 'flex-direction: column;'" }, {
|
||||
t("display: flex;"),
|
||||
t("flex-direction: column;"),
|
||||
i(0),
|
||||
}),
|
||||
-- Grid
|
||||
s({ trig = "dg", dscr = "Add 'display: grid;'" }, {
|
||||
s({ trig = "dg", desc = "Add 'display: grid;'" }, {
|
||||
t("display: grid;"),
|
||||
i(0),
|
||||
}),
|
||||
-- Block
|
||||
s({ trig = "db", dscr = "Add 'display: block;'" }, {
|
||||
s({ trig = "db", desc = "Add 'display: block;'" }, {
|
||||
t("display: block;"),
|
||||
i(0),
|
||||
}),
|
||||
-- None
|
||||
s({ trig = "dn", dscr = "Add 'display: none;'" }, {
|
||||
s({ trig = "dn", desc = "Add 'display: none;'" }, {
|
||||
t("display: none;"),
|
||||
i(0),
|
||||
}),
|
||||
-- CSS Variables
|
||||
s({ trig = "v", dscr = "Add CSS variable" }, {
|
||||
s({ trig = "v", desc = "Add CSS variable" }, {
|
||||
t("var(--"),
|
||||
i(1),
|
||||
t(")"),
|
||||
i(0),
|
||||
}),
|
||||
-- Margin
|
||||
s({ trig = "m", dscr = "Add 'margin: ;'" }, {
|
||||
s({ trig = "m", desc = "Add 'margin: ;'" }, {
|
||||
t("margin: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "mt", dscr = "Add 'margin-top: ;'" }, {
|
||||
s({ trig = "mt", desc = "Add 'margin-top: ;'" }, {
|
||||
t("margin-top: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "mr", dscr = "Add 'margin-right: ;'" }, {
|
||||
s({ trig = "mr", desc = "Add 'margin-right: ;'" }, {
|
||||
t("margin-right: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "mb", dscr = "Add 'margin-bottom: ;'" }, {
|
||||
s({ trig = "mb", desc = "Add 'margin-bottom: ;'" }, {
|
||||
t("margin-bottom: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "ml", dscr = "Add 'margin-left: ;'" }, {
|
||||
s({ trig = "ml", desc = "Add 'margin-left: ;'" }, {
|
||||
t("margin-left: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
-- Padding
|
||||
s({ trig = "p", dscr = "Add 'padding: ;'" }, {
|
||||
s({ trig = "p", desc = "Add 'padding: ;'" }, {
|
||||
t("padding: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "pt", dscr = "Add 'padding-top: ;'" }, {
|
||||
s({ trig = "pt", desc = "Add 'padding-top: ;'" }, {
|
||||
t("padding-top: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "pr", dscr = "Add 'padding-right: ;'" }, {
|
||||
s({ trig = "pr", desc = "Add 'padding-right: ;'" }, {
|
||||
t("padding-right: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "pb", dscr = "Add 'padding-bottom: ;'" }, {
|
||||
s({ trig = "pb", desc = "Add 'padding-bottom: ;'" }, {
|
||||
t("padding-bottom: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "pl", dscr = "Add 'padding-left: ;'" }, {
|
||||
s({ trig = "pl", desc = "Add 'padding-left: ;'" }, {
|
||||
t("padding-left: "),
|
||||
i(1),
|
||||
t(";"),
|
||||
|
||||
@@ -4,19 +4,19 @@ local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
|
||||
return {
|
||||
s({ trig = "clg", dscr = "console.log" }, {
|
||||
s({ trig = "clg", desc = "console.log" }, {
|
||||
t("console.log("),
|
||||
i(1),
|
||||
t(")"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "Js", dscr = "JSON.stringify" }, {
|
||||
s({ trig = "Js", desc = "JSON.stringify" }, {
|
||||
t("JSON.stringify("),
|
||||
i(1),
|
||||
t(")"),
|
||||
i(0),
|
||||
}),
|
||||
s({ trig = "Jsf", dscr = "JSON.stringify (formatted)" }, {
|
||||
s({ trig = "Jsf", desc = "JSON.stringify (formatted)" }, {
|
||||
t("JSON.stringify("),
|
||||
i(1),
|
||||
t(", 0, 2)"),
|
||||
|
||||
@@ -915,21 +915,21 @@ end
|
||||
|
||||
return {
|
||||
s(
|
||||
{ trig = "^h", regTrig = true, dscr = "Markdown header" },
|
||||
{ trig = "^h", regTrig = true, desc = "Markdown header" },
|
||||
fmta("# <><>", {
|
||||
d(1, get_visual),
|
||||
i(0),
|
||||
})
|
||||
),
|
||||
s(
|
||||
{ trig = "^sec", regTrig = true, dscr = "Markdown header" },
|
||||
{ trig = "^sec", regTrig = true, desc = "Markdown header" },
|
||||
fmta("## <><>", {
|
||||
d(1, get_visual),
|
||||
i(0),
|
||||
})
|
||||
),
|
||||
s(
|
||||
{ trig = "^ssec", regTrig = true, dscr = "Markdown header" },
|
||||
{ trig = "^ssec", regTrig = true, desc = "Markdown header" },
|
||||
fmta("### <><>", {
|
||||
d(1, get_visual),
|
||||
i(0),
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
local cmd = vim.cmd
|
||||
local map = vim.keymap.set
|
||||
|
||||
cmd([[
|
||||
source ~/.vim/init/base.vim
|
||||
source ~/.vim/init/mappings.vim
|
||||
]])
|
||||
|
||||
require("keymaps")
|
||||
|
||||
map({ "n", "v" }, "<leader>p", '<cmd>call VSCodeNotify("workbench.action.quickOpen")<cr>')
|
||||
|
||||
Reference in New Issue
Block a user