mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 16:41:43 +05:30
feat(Neovim): Sensible keymaps, prune plugins, Kickstart.nvim LSP code
This commit is contained in:
@@ -1,180 +1,4 @@
|
||||
local M = {}
|
||||
---@type table<string, table<string, string[]>>
|
||||
M.dials_by_ft = {}
|
||||
|
||||
---@param increment boolean
|
||||
---@param g? boolean
|
||||
function M.dial(increment, g)
|
||||
local mode = vim.fn.mode(true)
|
||||
-- Use visual commands for VISUAL 'v', VISUAL LINE 'V' and VISUAL BLOCK '\22'
|
||||
local is_visual = mode == "v" or mode == "V" or mode == "\22"
|
||||
local func = (increment and "inc" or "dec") .. (g and "_g" or "_") .. (is_visual and "visual" or "normal")
|
||||
local group = M.dials_by_ft[vim.bo.filetype] or "default"
|
||||
return require("dial.map")[func](group)
|
||||
end
|
||||
|
||||
return {
|
||||
-- Better increment/decrement with <Ctrl+a>
|
||||
{
|
||||
"monaqa/dial.nvim",
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<C-a>", function() return M.dial(true) end, expr = true, desc = "Increment", mode = { "n", "v" } },
|
||||
{ "<C-x>", function() return M.dial(false) end, expr = true, desc = "Decrement", mode = { "n", "v" } },
|
||||
{ "g<C-a>", function() return M.dial(true, true) end, expr = true, desc = "Increment", mode = { "n", "v" } },
|
||||
{ "g<C-x>", function() return M.dial(false, true) end, expr = true, desc = "Decrement", mode = { "n", "v" } },
|
||||
},
|
||||
opts = function()
|
||||
local augend = require("dial.augend")
|
||||
|
||||
local logical_alias = augend.constant.new({
|
||||
elements = { "&&", "||" },
|
||||
word = false,
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
local ordinal_numbers = augend.constant.new({
|
||||
-- elements through which we cycle. When we increment, we go down
|
||||
-- On decrement we go up
|
||||
elements = {
|
||||
"first",
|
||||
"second",
|
||||
"third",
|
||||
"fourth",
|
||||
"fifth",
|
||||
"sixth",
|
||||
"seventh",
|
||||
"eighth",
|
||||
"ninth",
|
||||
"tenth",
|
||||
},
|
||||
-- if true, it only matches strings with word boundary. firstDate wouldn't work for example
|
||||
word = false,
|
||||
-- do we cycle back and forth (tenth to first on increment, first to tenth on decrement).
|
||||
-- Otherwise nothing will happen when there are no further values
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
local weekdays = augend.constant.new({
|
||||
elements = {
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
"Sunday",
|
||||
},
|
||||
word = true,
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
local months = augend.constant.new({
|
||||
elements = {
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
},
|
||||
word = true,
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
local capitalized_boolean = augend.constant.new({
|
||||
elements = {
|
||||
"True",
|
||||
"False",
|
||||
},
|
||||
word = true,
|
||||
cyclic = true,
|
||||
})
|
||||
|
||||
return {
|
||||
dials_by_ft = {
|
||||
css = "css",
|
||||
javascript = "typescript",
|
||||
javascriptreact = "typescript",
|
||||
json = "json",
|
||||
lua = "lua",
|
||||
markdown = "markdown",
|
||||
python = "python",
|
||||
sass = "css",
|
||||
scss = "css",
|
||||
typescript = "typescript",
|
||||
typescriptreact = "typescript",
|
||||
cs = "csharp",
|
||||
},
|
||||
groups = {
|
||||
default = {
|
||||
augend.integer.alias.decimal, -- nonnegative decimal number (0, 1, 2, 3, ...)
|
||||
augend.integer.alias.hex, -- nonnegative hex number (0x01, 0x1a1f, etc.)
|
||||
augend.date.alias["%Y/%m/%d"], -- date (2022/02/19, etc.)
|
||||
},
|
||||
typescript = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
augend.constant.alias.bool, -- boolean value (true <-> false)
|
||||
logical_alias,
|
||||
augend.constant.new({ elements = { "let", "const" } }),
|
||||
ordinal_numbers,
|
||||
weekdays,
|
||||
months,
|
||||
},
|
||||
css = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
augend.hexcolor.new({
|
||||
case = "lower",
|
||||
}),
|
||||
augend.hexcolor.new({
|
||||
case = "upper",
|
||||
}),
|
||||
},
|
||||
markdown = {
|
||||
augend.misc.alias.markdown_header,
|
||||
ordinal_numbers,
|
||||
weekdays,
|
||||
months,
|
||||
},
|
||||
json = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
augend.semver.alias.semver, -- versioning (v1.1.2)
|
||||
},
|
||||
lua = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
augend.constant.alias.bool, -- boolean value (true <-> false)
|
||||
augend.constant.new({
|
||||
elements = { "and", "or" },
|
||||
word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
|
||||
cyclic = true, -- "or" is incremented into "and".
|
||||
}),
|
||||
ordinal_numbers,
|
||||
weekdays,
|
||||
months,
|
||||
},
|
||||
python = {
|
||||
augend.integer.alias.decimal, -- nonnegative and negative decimal number
|
||||
capitalized_boolean,
|
||||
logical_alias,
|
||||
ordinal_numbers,
|
||||
weekdays,
|
||||
months,
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("dial.config").augends:register_group(opts.groups)
|
||||
M.dials_by_ft = opts.dials_by_ft
|
||||
end,
|
||||
},
|
||||
|
||||
-- Navigate between NVIM & Tmux splits seamlessly
|
||||
{
|
||||
"christoomey/vim-tmux-navigator",
|
||||
@@ -231,50 +55,11 @@ return {
|
||||
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
dependencies = {
|
||||
"echasnovski/mini.icons",
|
||||
},
|
||||
opts = {
|
||||
defaults = {
|
||||
["<leader>r"] = { name = "+refactor" },
|
||||
},
|
||||
icons = {
|
||||
-- set icon mappings to true if you have a Nerd Font
|
||||
mappings = vim.g.have_nerd_font,
|
||||
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
|
||||
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
|
||||
keys = vim.g.have_nerd_font and {} or {
|
||||
Up = '<Up> ',
|
||||
Down = '<Down> ',
|
||||
Lefj = '<Left> ',
|
||||
Right = '<Right> ',
|
||||
C = '<C-…> ',
|
||||
M = '<M-…> ',
|
||||
D = '<D-…> ',
|
||||
S = '<S-…> ',
|
||||
CR = '<CR> ',
|
||||
Esc = '<Esc> ',
|
||||
ScrollWheelDown = '<ScrollWheelDown> ',
|
||||
ScrollWheelUp = '<ScrollWheelUp> ',
|
||||
NL = '<NL> ',
|
||||
BS = '<BS> ',
|
||||
Space = '<Space> ',
|
||||
Tab = '<Tab> ',
|
||||
F1 = '<F1>',
|
||||
F2 = '<F2>',
|
||||
F3 = '<F3>',
|
||||
F4 = '<F4>',
|
||||
F5 = '<F5>',
|
||||
F6 = '<F6>',
|
||||
F7 = '<F7>',
|
||||
F8 = '<F8>',
|
||||
F9 = '<F9>',
|
||||
F10 = '<F10>',
|
||||
F11 = '<F11>',
|
||||
F12 = '<F12>',
|
||||
},
|
||||
},
|
||||
|
||||
-- Document existing key chains
|
||||
spec = {
|
||||
{ "<leader>c", group = "Code" },
|
||||
@@ -283,8 +68,9 @@ return {
|
||||
{ "<leader>f", group = "File Operations" },
|
||||
{ "<leader>g", group = "Git" },
|
||||
{ "<leader>f", group = "Find and List Things" },
|
||||
{ "<leader>h", group = "Help" },
|
||||
{ "<leader>n", group = "NVIM Things" },
|
||||
{ "<leader>q", group = "Database Query" },
|
||||
{ "<leader>q", group = "Database" },
|
||||
{ "<leader>s", group = "Search/Grep Things" },
|
||||
{ "<leader>t", group = "Unit Test Operations" },
|
||||
{ "<leader>x", group = "Delete/Remove Something" },
|
||||
@@ -296,6 +82,7 @@ return {
|
||||
-- TIP: autocmd to autoload sessions at: ../config/autocmd.lua
|
||||
{
|
||||
"folke/persistence.nvim",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
event = "BufReadPre",
|
||||
opts = {
|
||||
-- Session files stored at: ~/.config/nvim/sessions/
|
||||
|
||||
Reference in New Issue
Block a user