1
Fork 0

Edit neovim snippets

This commit is contained in:
prescientmoon 2025-05-27 05:55:41 +02:00
commit 53894a5724
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
11 changed files with 129 additions and 88 deletions

View file

@ -24,6 +24,14 @@ local function runLocal(functionName)
end end
end end
-- local tempest = require("my.tempest")
-- tempest.set_keymap({
-- mapping = "<leader>lf",
-- action = "<cmd>source %<cr>",
-- buffer = true,
-- desc = "Run .[s]etup() in current file"
-- })
vim.keymap.set( vim.keymap.set(
"n", "n",
"<leader>lf", "<leader>lf",

View file

@ -8,5 +8,3 @@ local nix = require("nix")
tempest.configureMany(nix.pre) tempest.configureMany(nix.pre)
require("my.lazy").setup() require("my.lazy").setup()
tempest.configureMany(nix.post) tempest.configureMany(nix.post)
require("my.helpers.folding").setup()

View file

@ -25,10 +25,11 @@
"lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" }, "lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" },
"lean": { "branch": "main", "commit": "202513a398e780dac32d36159181a8299d9cfd12" }, "lean": { "branch": "main", "commit": "202513a398e780dac32d36159181a8299d9cfd12" },
"live-command": { "branch": "main", "commit": "d460067d47948725a6f25b20f31ea8bbfdfe4622" }, "live-command": { "branch": "main", "commit": "d460067d47948725a6f25b20f31ea8bbfdfe4622" },
"lspconfig": { "branch": "master", "commit": "b1729954329236f59d075bec79fdee7a6f3ce88b" }, "lspconfig": { "branch": "master", "commit": "641e567f975feab3815b47c7d29e6148e07afa77" },
"lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
"luasnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "luasnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"mini.ai": { "branch": "main", "commit": "ebb04799794a7f94628153991e6334c3304961b8" }, "mini.ai": { "branch": "main", "commit": "ebb04799794a7f94628153991e6334c3304961b8" },
"mini.align": { "branch": "main", "commit": "969bdcdf9b88e30bda9cb8ad6f56afed208778ad" },
"mini.comment": { "branch": "main", "commit": "a56581c40c19fa26f2b39da72504398de3173c5a" }, "mini.comment": { "branch": "main", "commit": "a56581c40c19fa26f2b39da72504398de3173c5a" },
"mini.files": { "branch": "main", "commit": "84efb81e5207ae8c41f54abdafb79c6212fc0971" }, "mini.files": { "branch": "main", "commit": "84efb81e5207ae8c41f54abdafb79c6212fc0971" },
"mini.operators": { "branch": "main", "commit": "7cb4dc66c51a3d736d347bbc517dc73dc7d28888" }, "mini.operators": { "branch": "main", "commit": "7cb4dc66c51a3d736d347bbc517dc73dc7d28888" },

View file

@ -1,23 +0,0 @@
local M = {}
local function createFold(name)
local commentstring = vim.o.commentstring
local start_comment = string.gsub(commentstring, "%%s", "{{{ " .. name)
local end_comment = string.gsub(commentstring, "%%s", "}}}")
-- Leave visual mode
local esc = vim.api.nvim_replace_termcodes("<esc>", true, false, true)
vim.api.nvim_feedkeys(esc, "x", false)
vim.cmd(":'>put='" .. end_comment .. "'")
vim.cmd(":'<-1put='" .. start_comment .. "'")
end
function M.setup()
vim.keymap.set("v", "<C-i>", function()
local name = vim.fn.input("Fold name: ")
createFold(name)
end, { desc = "Create fold markers around area" })
end
return M

View file

@ -1,43 +0,0 @@
local M = {}
local function swap(key)
vim.keymap.set({ "n", "v" }, key, "g" .. key, { buffer = true })
vim.keymap.set({ "n", "v" }, "g" .. key, key, { buffer = true })
end
local function unswap(key)
vim.keymap.del({ "n", "v" }, key)
vim.keymap.del({ "n", "v" }, "g" .. key)
end
function M.enable()
vim.opt.wrap = true
swap("j")
swap("k")
swap("<up>")
swap("<down>")
swap("0")
swap("$")
end
function M.disable()
vim.opt.wrap = false
unswap("j")
unswap("k")
unswap("<up>")
unswap("<down>")
unswap("0")
unswap("$")
end
function M.toggle()
if vim.opt.wrap == true then
M.disable()
else
M.enable()
end
end
return M

View file

@ -1,8 +1,8 @@
local M = {} local M = {}
local function importFrom(p) -- local function importFrom(p)
return { import = p } -- return { import = p }
end -- end
function M.setup() function M.setup()
require("lazy").setup({ require("lazy").setup({

View file

@ -57,7 +57,8 @@ function H.mergeTables(t1, t2)
end end
-- }}} -- }}}
-- }}} -- }}}
-- {{{ API wrappers
-- API wrappers
-- {{{ Keymaps -- {{{ Keymaps
function M.set_keymap(opts, context) function M.set_keymap(opts, context)
if context == nil then if context == nil then
@ -112,7 +113,64 @@ function M.create_autocmd(opts)
}) })
end end
-- }}} -- }}}
-- {{{ Wrapping
local function swapLinewiseKeybinds(key)
vim.keymap.set({ "n", "v" }, key, "g" .. key, { buffer = true })
vim.keymap.set({ "n", "v" }, "g" .. key, key, { buffer = true })
end
local function unswapLinewiseKeybinds(key)
vim.keymap.del({ "n", "v" }, key)
vim.keymap.del({ "n", "v" }, "g" .. key)
end
M.wrapping = {}
function M.wrapping.enable()
vim.opt.wrap = true
swapLinewiseKeybinds("j")
swapLinewiseKeybinds("k")
swapLinewiseKeybinds("<up>")
swapLinewiseKeybinds("<down>")
swapLinewiseKeybinds("0")
swapLinewiseKeybinds("$")
end
function M.wrapping.disable()
vim.opt.wrap = false
unswapLinewiseKeybinds("j")
unswapLinewiseKeybinds("k")
unswapLinewiseKeybinds("<up>")
unswapLinewiseKeybinds("<down>")
unswapLinewiseKeybinds("0")
unswapLinewiseKeybinds("$")
end
function M.wrapping.toggle()
if vim.opt.wrap == true then
M.wrapping.disable()
else
M.wrapping.enable()
end
end
-- }}} -- }}}
-- {{{ Folding
function M.createVisualFold(name)
local commentstring = vim.o.commentstring
local start_comment = string.gsub(commentstring, "%%s", "{{{ " .. name)
local end_comment = string.gsub(commentstring, "%%s", "}}}")
-- Leave visual mode
local esc = vim.api.nvim_replace_termcodes("<esc>", true, false, true)
vim.api.nvim_feedkeys(esc, "x", false)
vim.cmd(":'>put='" .. end_comment .. "'")
vim.cmd(":'<-1put='" .. start_comment .. "'")
end
-- }}}
-- {{{ Main config runtime -- {{{ Main config runtime
local function recursive_assign(source, destination) local function recursive_assign(source, destination)
for key, value in pairs(source) do for key, value in pairs(source) do

View file

@ -9,16 +9,18 @@
let let
# Toggles for including tooling related to a given language # Toggles for including tooling related to a given language
packedTargets = { packedTargets = {
csharp = false;
elm = false; elm = false;
tooling = true; # Stuff useful for config editing
latex = true; latex = true;
lua = true; lua = true;
nix = true; nix = true;
odin = false;
purescript = false; purescript = false;
python = false; python = false;
rust = false; rust = false;
typst = true; typst = true;
web = true; web = true;
csharp = false;
}; };
korora = inputs.korora.lib; korora = inputs.korora.lib;
@ -32,7 +34,7 @@ let
generated = generated =
with nlib; with nlib;
generateConfig { generateConfig {
# {{{ Pre-plugin config # Pre-plugin config
pre = { pre = {
# {{{ General options # {{{ General options
"0:general-options" = { "0:general-options" = {
@ -104,7 +106,6 @@ let
action.vim.opt.winblend = 0; action.vim.opt.winblend = 0;
}; };
# }}} # }}}
# {{{ Starter page # {{{ Starter page
callback = callback =
# lua # lua
@ -191,15 +192,17 @@ let
(unmap "<C-^>") (unmap "<C-^>")
(nmap "Q" ":wqa<cr>" "Save all files and [q]uit") (nmap "Q" ":wqa<cr>" "Save all files and [q]uit")
(nmap "<leader>rw" ":%s/<C-r><C-w>/" "[R]eplace [w]ord in file") (nmap "<leader>rw" ":%s/<C-r><C-w>/" "[R]eplace [w]ord in file")
(nmap "<leader>sw" (require "my.helpers.wrap" /toggle) "toggle word [w]rap") (nmap "<leader>sw" (tempest /wrapping/toggle) "toggle word [w]rap")
(nmap "<leader>ss" ( (nmap "<leader>ss" (thunk "vim.opt.spell = not vim.o.spell") "toggle [s]pell checker")
# lua
thunk "vim.opt.spell = not vim.o.spell"
) "toggle [s]pell checker")
(nmap "<leader>yp" "<cmd>!curl --data-binary @% https://paste.rs | wl-copy<cr>" (nmap "<leader>yp" "<cmd>!curl --data-binary @% https://paste.rs | wl-copy<cr>"
"[y]ank [p]aste.rs link to clipboard" "[y]ank [p]aste.rs link to clipboard"
) )
# }}} # }}}
{
mode = "v";
mapping = "<C-i>";
action = _: tempest /createVisualFold (vim /fn/input "Fold name: ");
}
]; ];
# }}} # }}}
# {{{ Autocmds # {{{ Autocmds
@ -221,7 +224,7 @@ let
"tex" "tex"
]; ];
group = "EnableWrapMovement"; group = "EnableWrapMovement";
action = require "my.helpers.wrap" /enable; action = tempest /wrapping/enable;
} }
# }}} # }}}
]; ];
@ -317,8 +320,8 @@ let
}; };
# }}} # }}}
}; };
# }}}
# {{{ Plugins # Plugins
lazy = { lazy = {
# {{{ libraries # {{{ libraries
# {{{ plenary # {{{ plenary
@ -753,6 +756,24 @@ let
}; };
}; };
# }}} # }}}
# {{{ mini.align
mini-align = {
package = "echasnovski/mini.align";
name = "mini.align";
config = true;
keys = [
{
mode = "nxv";
mapping = "ga";
}
{
mode = "nxv";
mapping = "gA";
}
];
};
# }}}
# {{{ mini.comment # {{{ mini.comment
mini-comment = { mini-comment = {
package = "echasnovski/mini.comment"; package = "echasnovski/mini.comment";
@ -978,8 +999,15 @@ let
pkgs.nodePackages.purs-tidy pkgs.nodePackages.purs-tidy
] ]
++ optionals csharp [ pkgs.csharp-ls ] ++ optionals csharp [ pkgs.csharp-ls ]
++ optionals odin [ pkgs.ols ]
++ optionals tooling [
pkgs.hyprls
# REASON: not yet available on stable
upkgs.just-lsp
]
); );
# }}} # }}}
dependencies.lua = [ dependencies.lua = [
"neoconf" "neoconf"
"neodev" "neodev"
@ -1061,6 +1089,13 @@ let
elmls = { }; elmls = { };
csharp_ls = { }; csharp_ls = { };
ols = { }; # Odin ols = { }; # Odin
hyprls = { };
# I have the justfile formatter
just.on_attach = client: ''
${client}.server_capabilities.documentFormattingProvider = false
${client}.server_capabilities.documentRangeFormattingProvider = false
'';
}; };
}; };
# }}} # }}}
@ -1110,6 +1145,8 @@ let
nix = [ "nixfmt" ]; nix = [ "nixfmt" ];
css = prettier; css = prettier;
markdown = prettier; markdown = prettier;
just.lsp_format = "never";
}; };
}; };
# }}} # }}}
@ -1589,7 +1626,6 @@ let
# }}} # }}}
# }}} # }}}
}; };
# }}}
}; };
# {{{ extraRuntime # {{{ extraRuntime
@ -1688,4 +1724,6 @@ in
mirosSnippetCache mirosSnippetCache
]; ];
# }}} # }}}
home.sessionVariables.MANPAGER = "${lib.getExe neovim} +Man!";
} }

View file

@ -9,3 +9,4 @@ block auto
abbr sim abbr sim
abbr approx ≃ abbr approx ≃
abbr cong ≅ abbr cong ≅
abbr fcomp ∘

View file

@ -87,9 +87,12 @@ block text
string $ string $
name inline math name inline math
snip \$$1\$$0 snip \$$1\$$0
-- }}}
abbr pause \pause abbr pause \pause
-- }}} string emph
desc emphasise some text
snip \emph{$1}$0
string forcecr string forcecr
desc Force the content onto a new line desc Force the content onto a new line
@ -271,7 +274,7 @@ block math
for noperator <- @⟨ordop,land,lor,equiv,pmod,ldots,cdots,perp,angle,sup⟩ for noperator <- @⟨ordop,land,lor,equiv,pmod,ldots,cdots,perp,angle,sup⟩
abbr @noperator \\@noperator abbr @noperator \\@noperator
for operator <- @⟨cancel,overline,hat,tilde,vec,bar,abs,norm,prob,diprod,sin,cos,sqrt,ln,lrb,zmod,gen,pmob⟩ for operator <- @⟨cancel,overline,hat,tilde,vec,bar,abs,norm,prob,diprod,sin,cos,sqrt,lrb,zmod,gen,pmob⟩
string @operator string @operator
snip \\@operator$|1⟨{$1}, $0⟩ snip \\@operator$|1⟨{$1}, $0⟩

View file

@ -54,7 +54,7 @@ block auto
name limit to @limtarget name limit to @limtarget
snip lim_($1 → @limtargetsymbol) $0 snip lim_($1 → @limtargetsymbol) $0
for operator <- @⟨eq,neq,defas,leq,geq,lt,gt,iip,iib,iff⟩ for operator <- @⟨eq,neq,defas,leq,geq,llt,ggt,iip,iib,iff⟩
for symbol <- @⟨@operator:=,≠,≔,≤,≥,<,>,⟹,⟸,⟺⟩ for symbol <- @⟨@operator:=,≠,≔,≤,≥,<,>,⟹,⟸,⟺⟩
abbr @operator @symbol abbr @operator @symbol