Started rewriting my neovim config
This commit is contained in:
parent
686bdd12c4
commit
47d704ad01
17 changed files with 181 additions and 122 deletions
dotfiles/neovim/lua/my/plugins
|
@ -3,25 +3,43 @@ local arpeggio = vim.fn["arpeggio#map"]
|
|||
|
||||
local M = {}
|
||||
|
||||
function M.chord(mode, lhs, rhs, opts)
|
||||
---Create an arpeggio mapping
|
||||
---@param mode string
|
||||
---@param lhs string
|
||||
---@param rhs string
|
||||
---@param opts table|nil
|
||||
local function chord(mode, lhs, rhs, opts)
|
||||
if string.len(mode) > 1 then
|
||||
for i = 1, #mode do
|
||||
local c = mode:sub(i, i)
|
||||
M.chord(c, lhs, rhs, opts)
|
||||
chord(c, lhs, rhs, opts)
|
||||
end
|
||||
else
|
||||
local options = helpers.mergeTables(opts or {}, { noremap = true })
|
||||
local settings = options.settings or ""
|
||||
|
||||
if options.silent then settings = settings .. "s" end
|
||||
if options.silent then
|
||||
settings = settings .. "s"
|
||||
end
|
||||
|
||||
arpeggio(mode, settings, not options.noremap, lhs, rhs)
|
||||
end
|
||||
end
|
||||
|
||||
function M.chordSilent(mode, lhs, rhs, opts)
|
||||
---Create a silent arpeggio mapping
|
||||
---@param mode string
|
||||
---@param lhs string
|
||||
---@param rhs string
|
||||
---@param opts table|nil
|
||||
local function chordSilent(mode, lhs, rhs, opts)
|
||||
local options = helpers.mergeTables(opts or {}, { silent = true })
|
||||
M.chord(mode, lhs, rhs, options)
|
||||
chord(mode, lhs, rhs, options)
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
chordSilent("n", "ji", ":silent :write<cr>") -- Saving
|
||||
chord("i", "jk", "<Esc>") -- Remap Esc to jk
|
||||
chord("nv", "cp", '"+') -- Press cp to use the global clipboard
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,18 +1,7 @@
|
|||
local arpeggio = require("my.plugins.arpeggio")
|
||||
local lspconfig = require("my.plugins.lspconfig")
|
||||
|
||||
local M = {}
|
||||
|
||||
local idrisChords = {
|
||||
sc = "case_split",
|
||||
mc = "make_case",
|
||||
ml = "make_lemma",
|
||||
es = "expr_search",
|
||||
gd = "generate_def",
|
||||
rh = "refine_hole",
|
||||
ac = "add_clause"
|
||||
}
|
||||
|
||||
function M.setup()
|
||||
local idris2 = require("idris2")
|
||||
|
||||
|
@ -21,14 +10,28 @@ function M.setup()
|
|||
on_attach = function(client, bufnr)
|
||||
lspconfig.on_attach(client, bufnr)
|
||||
|
||||
for key, value in pairs(idrisChords) do
|
||||
arpeggio.chord("n", "i" .. key,
|
||||
":lua require('idris2.code_action')." .. value .. "()<CR>",
|
||||
{ settings = "b" })
|
||||
local function nmap(from, to, desc)
|
||||
vim.keymap.set("n", "<leader>I" .. from, function()
|
||||
require("idris2.code_action")[to]()
|
||||
end, { desc = desc, bufnr = true })
|
||||
end
|
||||
end
|
||||
|
||||
nmap("C", "make_case", "Make [c]plit")
|
||||
nmap("L", "make_lemma", "Make [l]emma")
|
||||
nmap("c", "add_clause", "Add [c]lause")
|
||||
nmap("s", "expr_search", "Expression [s]earch")
|
||||
nmap("d", "generate_def", "Generate [d]efinition")
|
||||
nmap("s", "case_split", "Case [s]plit")
|
||||
nmap("h", "refine_hole", "Refine [h]ole")
|
||||
|
||||
local status, wk = pcall(require, "which-key")
|
||||
|
||||
if status then
|
||||
wk.register({ ["<leader>I"] = { name = "[I]dris", buffer = bufnr } })
|
||||
end
|
||||
end,
|
||||
},
|
||||
client = { hover = { use_split = true } }
|
||||
client = { hover = { use_split = true } },
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ function M.setup()
|
|||
require("my.plugins.vimtex").setup()
|
||||
-- require("my.plugins.lean").setup()
|
||||
require("my.plugins.notify").setup()
|
||||
require("my.plugins.iron").setup()
|
||||
end)
|
||||
|
||||
if env.neovide.active() then
|
||||
|
@ -59,7 +58,8 @@ function M.setup()
|
|||
require("my.plugins.hydra").setup()
|
||||
require("my.plugins.clipboard-image").setup()
|
||||
require("my.plugins.mind").setup()
|
||||
require("my.plugins.ufo").setup()
|
||||
-- require("my.plugins.ufo").setup()
|
||||
require("my.plugins.arpeggio").setup()
|
||||
|
||||
-- require("my.plugins.slam").setup()
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ function M.setup()
|
|||
|
||||
local status, wk = pcall(require, "which-key")
|
||||
|
||||
if status then wk.register({ ["<leader>i"] = { name = "Iron repl commands" } }) end
|
||||
if status then wk.register({ ["<leader>i"] = { name = "[I]ron repl commands", s = {name = "[s]end"}, m = "[m]ark" } }) end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -16,7 +16,7 @@ function M.on_attach(client, bufnr)
|
|||
-- }}}
|
||||
-- {{{ Keymap helpers
|
||||
local opts = function(desc)
|
||||
return { noremap = true, silent = true, desc = desc }
|
||||
return { noremap = true, silent = true, desc = desc, buffer = true }
|
||||
end
|
||||
|
||||
local nmap = function(from, to, desc)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
local arpeggio = require("my.plugins.arpeggio")
|
||||
|
||||
local M = {}
|
||||
|
||||
local function find_files_by_extension(extension)
|
||||
|
@ -14,18 +12,23 @@ local defaultTheme = "ivy"
|
|||
|
||||
local keybinds = {
|
||||
{ "<C-P>", "find_files", "Find files" },
|
||||
{ "<Leader>ft", find_files_by_extension("tex"), "Find tex files" },
|
||||
{ "<Leader>fl", find_files_by_extension("lua"), "Find lua files" },
|
||||
{ "<Leader>fp", find_files_by_extension("purs"), "Find purescript files" },
|
||||
{ "<Leader>d", "diagnostics", "Diagnostics" },
|
||||
{ "<C-F>", "live_grep", "Search in project" },
|
||||
{ "<Leader>t", "builtin", "Show builtin pickers" }
|
||||
{ "<Leader>ft", find_files_by_extension("tex"), "[F]ind [t]ex files" },
|
||||
{ "<Leader>fl", find_files_by_extension("lua"), "[F]ind [l]ua files" },
|
||||
{
|
||||
"<Leader>fp",
|
||||
find_files_by_extension("purs"),
|
||||
"[F]ind [p]urescript files",
|
||||
},
|
||||
{ "<Leader>d", "diagnostics", "[D]iagnostics" },
|
||||
{ "<C-F>", "live_grep", "[F]ind in project" },
|
||||
{ "<C-S-F>", "file_browser", "[F]ile browser" },
|
||||
{ "<Leader>t", "builtin", "[T]elescope pickers" },
|
||||
}
|
||||
|
||||
local chords = { { "jp", "file_browser" } }
|
||||
|
||||
local function mkAction(action)
|
||||
if not string.find(action, "theme=") then action = with_theme(action, defaultTheme) end
|
||||
if not string.find(action, "theme=") then
|
||||
action = with_theme(action, defaultTheme)
|
||||
end
|
||||
|
||||
return ":Telescope " .. action .. "<cr>"
|
||||
end
|
||||
|
@ -34,8 +37,6 @@ local function setupKeybinds()
|
|||
for _, mapping in pairs(keybinds) do
|
||||
vim.keymap.set("n", mapping[1], mkAction(mapping[2]), { desc = mapping[3] })
|
||||
end
|
||||
|
||||
for _, mapping in pairs(chords) do arpeggio.chord("n", mapping[1], mkAction(mapping[2])) end
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
|
@ -44,11 +45,11 @@ function M.setup()
|
|||
local settings = {
|
||||
defaults = { mappings = { i = { ["<C-h>"] = "which_key" } } },
|
||||
pickers = { find_files = { hidden = true } },
|
||||
extensions = { file_browser = { path = "%:p:h" } }
|
||||
extensions = { file_browser = { path = "%:p:h" } },
|
||||
}
|
||||
|
||||
require("telescope").setup(settings)
|
||||
require("telescope").load_extension "file_browser"
|
||||
require("telescope").load_extension("file_browser")
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -7,12 +7,12 @@ function M.setup()
|
|||
vim.o.foldenable = true
|
||||
|
||||
-- Using ufo provider need remap `zR` and `zM`.
|
||||
-- vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
|
||||
-- vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
|
||||
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
|
||||
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
|
||||
|
||||
-- Tell the server the capability of foldingRange,
|
||||
-- Neovim hasn't added foldingRange to default capabilities, users must add it manually
|
||||
-- require('ufo').setup()
|
||||
require('ufo').setup()
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,11 +1,27 @@
|
|||
local arpeggio = require("my.plugins.arpeggio")
|
||||
|
||||
local K = require("my.keymaps")
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
arpeggio.chordSilent("n", "vp", ":VimuxPromptCommand<CR>")
|
||||
arpeggio.chordSilent("n", "vc", ":VimuxRunCommand \"clear\"<CR>")
|
||||
arpeggio.chordSilent("n", "vl", ":VimuxRunLastCommand<CR>")
|
||||
--{{{ Register keybinds
|
||||
K.nmap("<leader>vp", ":VimuxPromptCommand<CR>", "[V]imux: [p]rompt for command")
|
||||
K.nmap("<leader>vc", ':VimuxRunCommand "clear"<CR>', "[V]imux: [c]lear pane")
|
||||
K.nmap(
|
||||
"<leader>vl",
|
||||
":VimuxRunLastCommand<CR>",
|
||||
"[V]imux: rerun [l]ast command"
|
||||
)
|
||||
--}}}
|
||||
--{{{ Register which-key docs
|
||||
local status, wk = pcall(require, "which-key")
|
||||
|
||||
if status then
|
||||
wk.register({
|
||||
["<leader>v"] = {
|
||||
name = "vimux",
|
||||
},
|
||||
})
|
||||
end
|
||||
--}}}
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue