kitchen sink...
just gonna put the changes that I can remember making here: - replace blink with native completion (omnifunc) - remove some unneeded plugins - add a misc function for making sure complex bindings don't cause flickering - remove some stale snippets - remove folding (I don't find myself folding that often)
This commit is contained in:
@ -1,64 +1,49 @@
|
||||
local map = core.misc.map
|
||||
local map, lz = core.misc.map, core.misc.lz
|
||||
local function feedkeys(keys)
|
||||
vim.api.nvim_feedkeys(
|
||||
vim.api.nvim_replace_termcodes(keys, true, false, true),
|
||||
"n", true)
|
||||
end
|
||||
|
||||
-- vim binds
|
||||
vim.g.mapleader = " " -- set leader key
|
||||
|
||||
map("x", "<leader>p", [["_dP]], { desc = "Greatest remap of all time." })
|
||||
map("n", "<esc>", ":nohlsearch<Bar>:echo<CR>", { desc = "Clear search." })
|
||||
-- move selected text up/down
|
||||
map("v", "<S-k>", ":m '<-2<CR>gv=gv", { desc = "Move selected text up." })
|
||||
map("v", "<S-j>", ":m '>+1<CR>gv=gv", { desc = "Move selected text down." })
|
||||
|
||||
-- the cursor STAYS IN THE MIDDLE
|
||||
map("n", "<S-j>", "mzJ`z<cmd>delm z<CR>") -- when combining lines
|
||||
map("n", "n", "nzzzv") -- when searching
|
||||
map("n", "N", "Nzzzv")
|
||||
map("n", "<C-d>", "<C-d>zz") -- half page jumping
|
||||
map("n", "<C-u>", "<C-u>zz")
|
||||
map("n", "<S-j>", lz "mzJ`z<cmd>delm z<CR>") -- when combining lines
|
||||
map("n", "n", lz "nzzzv") -- when searching
|
||||
map("n", "N", lz "Nzzzv")
|
||||
map("n", "<C-d>", lz "<C-d>zz") -- half page jumping
|
||||
map("n", "<C-u>", lz "<C-u>zz")
|
||||
|
||||
map({ "n", "i" }, "<C-c>", "<Esc>")
|
||||
|
||||
map("n", "<leader>x", function() -- execute order 111
|
||||
local fn = vim.fn.expand("%:p")
|
||||
if vim.fn.getftype(fn) == "file" then
|
||||
local perm = vim.fn.getfperm(fn)
|
||||
if string.match(perm, "x", 3) then
|
||||
vim.notify("Removed executable flags")
|
||||
vim.fn.setfperm(fn, string.sub(fn, 1, 2).."-"..string.sub(fn, 4, 5).."-"
|
||||
..string.sub(fn, 7, 8).."-")
|
||||
else
|
||||
vim.notify("Add executable flags")
|
||||
vim.fn.setfperm(fn, string.sub(fn, 1, 2).."x"..string.sub(fn, 4, 5).."x"
|
||||
..string.sub(fn, 7, 8).."x")
|
||||
end
|
||||
else
|
||||
vim.notify("File doesn't exist")
|
||||
end
|
||||
end, { desc = "toggle executable flag of the file" })
|
||||
|
||||
-- good spell suggestion ui
|
||||
-- (stolen from https://github.com/neovim/neovim/pull/25833)
|
||||
vim.keymap.set("n", "z=", function()
|
||||
local spell_on_choice = vim.schedule_wrap(function(_, idx)
|
||||
if type(idx) == "number" then
|
||||
vim.cmd("normal! "..idx.."z=")
|
||||
end
|
||||
end)
|
||||
|
||||
if vim.v.count > 0 then
|
||||
spell_on_choice(nil, vim.v.count)
|
||||
return
|
||||
end
|
||||
local cword = vim.fn.expand("<cword>")
|
||||
local prompt = "Change "..vim.inspect(cword).." to:"
|
||||
vim.ui.select(vim.fn.spellsuggest(cword, vim.o.lines), { prompt = prompt },
|
||||
spell_on_choice)
|
||||
end, { desc = "Shows spelling suggestions" })
|
||||
-- trigger completion menu
|
||||
-- (stolen from https://gist.github.com/MariaSolOs/2e44a86f569323c478e5a078d0cf98cc)
|
||||
map("i", "<C-n>", function()
|
||||
-- if the completion menu is already visible just go to the next item
|
||||
if vim.fn.pumvisible() ~= 0 then
|
||||
feedkeys("<C-n>")
|
||||
else
|
||||
if #vim.lsp.get_clients({ bufnr = 0 }) > 0 then
|
||||
vim.lsp.completion.get()
|
||||
else
|
||||
if vim.bo.omnifunc == "" then
|
||||
feedkeys("<C-x><C-n>")
|
||||
else
|
||||
feedkeys("<C-x><C-o>")
|
||||
end
|
||||
end
|
||||
end
|
||||
end, { desc = "Trigger/select next completion" })
|
||||
map("i", "<C-s>", "<C-x><C-s>", { desc = "Trigger spell completion" })
|
||||
map("n", "<C-s>", lz "<cmd>se spell<CR>ea<C-x><C-s><cmd>se nospell<CR>", { desc = "Trigger spell completion" })
|
||||
|
||||
-- quickfix
|
||||
map("n", "<M-j>", "<cmd>cnext<CR>")
|
||||
map("n", "<M-k>", "<cmd>cprev<CR>")
|
||||
map("n", "<M-c>", "<cmd>cclose<CR>")
|
||||
map("n", "<M-x>", "<cmd>cope<CR>")
|
||||
|
||||
-- man pages
|
||||
map("n", "<C-k>", "<cmd>Man<CR>")
|
||||
|
Reference in New Issue
Block a user