1
Fork 0

Better telescope setup

This commit is contained in:
Matei Adriel 2022-09-25 22:03:11 +02:00
parent 8e89a53a31
commit 7ada064c93
9 changed files with 123 additions and 124 deletions

View file

@ -81,6 +81,7 @@
sft (tap-macro lsft (layer-toggle shiftedQwerty)) ;; make this work differently based on the next key pressed sft (tap-macro lsft (layer-toggle shiftedQwerty)) ;; make this work differently based on the next key pressed
j (tap-macro 7 lsft) j (tap-macro 7 lsft)
;; spc (spc) ;; (tap-hold-next-release 130 spc lsft) ;; spc (spc) ;; (tap-hold-next-release 130 spc lsft)
tab (tap-hold-next 150 tab rctl)
) )
;; more "special" stuff ;; more "special" stuff
@ -102,7 +103,7 @@
(deflayer qwerty (deflayer qwerty
esc f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 del esc f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 del
grv 1 2 3 4 5 6 7 8 9 0 - = bspc grv 1 2 3 4 5 6 7 8 9 0 - = bspc
tab q w e r t y u i o p [ ] \ @tab q w e r t y u i o p [ ] \
@mth a s d f g h j k l ; ' ret @mth a s d f g h j k l ; ' ret
@sft z x c v b n m , . / rsft @sft z x c v b n m , . / rsft
@mov lsgt lmet lalt spc ralt rctl @mov lsgt lmet lalt spc ralt rctl

View file

@ -1,4 +1,5 @@
local arpeggio = require("my.plugins.arpeggio") local arpeggio = require("my.plugins.arpeggio")
local A = require("my.abbreviations")
print("Initializing nix keybinds...") print("Initializing nix keybinds...")
@ -11,3 +12,14 @@ arpeggio.chordSilent("n", "vb", ":VimuxRunCommand \"clear && spago build\"<CR>",
{ settings = "b" }) { settings = "b" })
vim.opt.expandtab = true -- Use spaces for the tab char vim.opt.expandtab = true -- Use spaces for the tab char
local abbreviations = {
{ "land", "/\\" },
{ "lor", "\\/" },
{ "tto", "->" },
{ "iip", "=>" },
{ "frl", "forall" },
{ "ott", "<-" } -- opposite of tto
}
A.manyLocalAbbr(abbreviations)

View file

@ -12,6 +12,11 @@ local abbreviations = {
{ "eps", "\\epsilon" }, { "eps", "\\epsilon" },
{ "delta", "\\delta" }, { "delta", "\\delta" },
{ "pi", "\\pi" }, { "pi", "\\pi" },
{ "psi", "\\psi" },
{ "psi", "\\psi" },
{ "alpha", "\\alpha" },
{ "beta", "\\beta" },
{ "gamma", "\\gamma" },
{ "nuls", "\\varnothing" }, { "nuls", "\\varnothing" },
-- Exponents -- Exponents
@ -23,6 +28,7 @@ local abbreviations = {
{ "e4", "^{4}" }, { "e4", "^{4}" },
{ "en", "^{n}" }, { "en", "^{n}" },
{ "etn", "^{-}" }, { "etn", "^{-}" },
{ "ett", "^{t}" },
{ "etp", "^{+}" }, { "etp", "^{+}" },
-- Subscripts -- Subscripts
@ -60,6 +66,9 @@ local abbreviations = {
{ "iff", "\\iff" }, { "iff", "\\iff" },
{ "land", "\\land" }, { "land", "\\land" },
{ "lor", "\\lor" }, { "lor", "\\lor" },
{ "ssin", "\\sin" },
{ "ccos", "\\cos" },
{ "lln", "\\ln" },
{ "frl", "\\forall" }, { "frl", "\\forall" },
{ "exs", "\\exists" }, { "exs", "\\exists" },
{ "iinf", "\\infty" }, { "iinf", "\\infty" },
@ -69,6 +78,7 @@ local abbreviations = {
{ "ccap", "\\cap" }, { "ccap", "\\cap" },
{ "nope", "\\bot" }, { "nope", "\\bot" },
{ "yee", "\\top" }, { "yee", "\\top" },
{ "ccan", "\\cancel" },
{ "mul", "\\cdot" }, { "mul", "\\cdot" },
{ "smul", "\\times" }, { "smul", "\\times" },
{ "texpl", "&& \\text{}" }, { "texpl", "&& \\text{}" },

View file

@ -18,7 +18,7 @@ function M.setup()
}, },
tex = { tex = {
img_dir = { "%:p:h", "img" }, img_dir = { "%:p:h", "img" },
affix = "\\includegraphics[]{%s}", affix = "\\includegraphics[width=\\textwidth]{%s}",
}, },
} }

View file

@ -1,83 +1,46 @@
local mapSilent = require("my.keymaps").mapSilent
local arpeggio = require("my.plugins.arpeggio") local arpeggio = require("my.plugins.arpeggio")
local M = {} local M = {}
local bindings = { local function find_files_by_extension(extension)
builtin = { return "find_files find_command=rg,--files,--glob=**/*." .. extension
-- Open files with control + P end
find_files = "<c-P>",
-- Search through files with control + F local keybinds = {
live_grep = "<c-F>", { "<C-P>", "find_files" },
{ "<Leader>ft", find_files_by_extension("tex") },
-- See diagnostics with space + d { "<Leader>fl", find_files_by_extension("lua") },
diagnostics = "<Leader>d", { "<C-F>", "live_grep" },
lsp_document_symbols = { chord = 1, key = "lds" }, { "<Leader>t", "builtin" },
-- Open a list with all the pickers
builtin = "<Leader>t",
-- List function, var names etc
treesitter = "<Leader>s",
-- Git stuff
git_commits = "<Leader>gj",
git_branches = "<Leader>gk"
},
["extensions.file_browser.file_browser"] = { chord = 1, key = "jp" },
extensions = {
unicode = {
picker = { mode = "i", kind = "dropdown", key = "ui", chord = 1 }
}
}
} }
local function setupKeybinds(obj, path) local chords = {
if path == nil then path = "" end { "jp", "file_browser" }
for name, keybinds in pairs(obj) do }
if (type(keybinds) == "table") and keybinds.key == nil then
-- This means we found a table of keybinds, so we go deeper
setupKeybinds(keybinds, path .. "." .. name)
else
local config = keybinds
local pickerArgument = ""
local key = config
local mode = "n"
local bind = mapSilent
if type(config) == "table" then local function mkAction(action)
key = config.key return ":Telescope " .. action .. "<cr>"
if config.mode ~= nil then mode = config.mode end end
if config.kind ~= nil then
pickerArgument = "require('telescope.themes').get_" .. local function setupKeybinds()
config.kind .. "({})" for _, mapping in pairs(keybinds) do
end vim.keymap.set("n", mapping[1], mkAction(mapping[2]))
if config.chord then
-- Useful for insert mode bindings
bind = arpeggio.chordSilent
end
end end
-- Maps the keybind to the action for _, mapping in pairs(chords) do
bind(mode, key, arpeggio.chord("n", mapping[1], mkAction(mapping[2]))
"<cmd>lua require('telescope" .. path .. "')." .. name .. "(" ..
pickerArgument .. ")<CR>")
end
end end
end end
function M.setup() function M.setup()
setupKeybinds(bindings) setupKeybinds()
local settings = { local settings = {
defaults = { mappings = { i = { ["<C-h>"] = "which_key" } } }, defaults = { mappings = { i = { ["<C-h>"] = "which_key" } } },
pickers = { find_files = { hidden = true } }, pickers = { find_files = { hidden = true } },
extensions = { extensions = {
file_browser = { file_browser = {
mappings = { path = "%:p:h"
-- Comment so this does not get collapsed
}
} }
} }
} }

View file

@ -19,6 +19,16 @@
"description": "Create a lemma", "description": "Create a lemma",
"body": ["\\begin{lemma}[$1] \\label{lem:$1}", "\t$0", "\\end{lemma}"] "body": ["\\begin{lemma}[$1] \\label{lem:$1}", "\t$0", "\\end{lemma}"]
}, },
"Example*": {
"prefix": "example*",
"description": "Create an example*",
"body": ["\\begin{example*}", "\t$0", "\\end{example*}"]
},
"Example": {
"prefix": "example",
"description": "Create an example",
"body": ["\\begin{example}[$1] \\label{exp:$1}", "\t$0", "\\end{example}"]
},
"Theorem": { "Theorem": {
"prefix": "theorem", "prefix": "theorem",
"description": "Create a theorem", "description": "Create a theorem",
@ -53,6 +63,11 @@
"description": "Exponent", "description": "Exponent",
"body": "^{$1}$0" "body": "^{$1}$0"
}, },
"Nth derivative": {
"prefix": "dd",
"description": "Nth derivative",
"body": "^{($1)}$0"
},
"Section": { "Section": {
"prefix": "section", "prefix": "section",
"description": "Add section", "description": "Add section",
@ -81,7 +96,12 @@
"Itemize": { "Itemize": {
"prefix": "item", "prefix": "item",
"body": ["\\\\begin{itemize}", "\t\\item $0", "\\\\end{itemize}"], "body": ["\\\\begin{itemize}", "\t\\item $0", "\\\\end{itemize}"],
"description": "Itemize" "description": "Itemize env"
},
"Enumerate": {
"prefix": "enum",
"body": ["\\\\begin{enumerate}", "\t\\item $0", "\\\\end{enumerate}"],
"description": "Enumerate env"
}, },
"Reference definition": { "Reference definition": {
"prefix": "rdef", "prefix": "rdef",
@ -98,11 +118,26 @@
"description": "Reference a theorem", "description": "Reference a theorem",
"body": "\\ref{thm:$1}$0" "body": "\\ref{thm:$1}$0"
}, },
"Sigma sum": {
"prefix": "bsum",
"description": "Create a sum using sigma notation",
"body": "\\sum_{$1 = $2}^{$3}$0"
},
"Pi product": {
"prefix": "bproduct",
"description": "Create a produt using pi notation",
"body": "\\product_{$1 = $2}^{$3}$0"
},
"Fraction": { "Fraction": {
"prefix": "frac", "prefix": "frac",
"description": "Create a fraction", "description": "Create a fraction",
"body": "\\frac{$1}{$2}$0" "body": "\\frac{$1}{$2}$0"
}, },
"Choose": {
"prefix": "binom",
"description": "Create a (n choose k) thingy",
"body": "\\binom{$1}{$2}$0"
},
"Limit": { "Limit": {
"prefix": "lim", "prefix": "lim",
"description": "Create a limit", "description": "Create a limit",
@ -123,6 +158,21 @@
"description": "Create a sqrt", "description": "Create a sqrt",
"body": "\\sqrt[$1]{$2}$0" "body": "\\sqrt[$1]{$2}$0"
}, },
"Sin": {
"prefix": "sin",
"description": "Create a sin call",
"body": "\\sin($1)$0"
},
"Cos": {
"prefix": "cos",
"description": "Create a cos call",
"body": "\\cos($1)$0"
},
"Ln": {
"prefix": "ln",
"description": "Create a ln call",
"body": "\\ln($1)$0"
},
"Real numbers": { "Real numbers": {
"prefix": "reals", "prefix": "reals",
"description": "", "description": "",
@ -171,7 +221,7 @@
"Force newline": { "Force newline": {
"prefix": "cr", "prefix": "cr",
"description": "Force newline in math mode", "description": "Force newline in math mode",
"body": "{\\ \\\\}" "body": "{\\ \\\\\\\\}"
}, },
"Aligned display math": { "Aligned display math": {
"prefix": "maligned", "prefix": "maligned",

View file

@ -2,34 +2,22 @@
"Definition": { "Definition": {
"prefix": "definition", "prefix": "definition",
"description": "Basic purescript definition", "description": "Basic purescript definition",
"body": [ "body": ["$1 :: $2", "$1 = $3"]
"$1 :: $2",
"$1 = $3"
]
}, },
"SProxy": { "SProxy": {
"prefix": "sproxy", "prefix": "sproxy",
"description": "Generate a proxy constant", "description": "Generate a proxy constant",
"body": [ "body": ["_$1 :: Proxy \"$1\"", "_$1 = Proxy"]
"_$1 :: Proxy \"$1\"",
"_$1 = Proxy"
]
}, },
"Proxy": { "Proxy": {
"prefix": "proxy", "prefix": "proxy",
"description": "Generate a proxy constant", "description": "Generate a proxy constant",
"body": [ "body": ["_$1 :: Proxy $1", "_$1 = Proxy"]
"_$1 :: Proxy $1",
"_$1 = Proxy"
]
}, },
"Prop": { "Prop": {
"prefix": "prop", "prefix": "prop",
"description": "Prop lens", "description": "Prop lens",
"body": [ "body": ["_$1 :: Lens' $2 $3", "_$1 = prop (Proxy :: _ \"$1\")"]
"_$1 :: Lens' $2 $3",
"_$1 = prop (Proxy :: _ \"$1\")"
]
}, },
"Variant constructor": { "Variant constructor": {
"prefix": "inj", "prefix": "inj",
@ -53,22 +41,21 @@
"Example code": { "Example code": {
"prefix": "ex", "prefix": "ex",
"description": "Provide example usage for some piece of code", "description": "Provide example usage for some piece of code",
"body" : [ "body": ["-- |", "-- | Ex:", "-- | ```purs", "-- | $0", "-- | ```"]
"-- |",
"-- | Ex:",
"-- | ```purs",
"-- | $0",
"-- | ```"
]
}, },
"Section": { "Section": {
"prefix": "section", "prefix": "section",
"description": "Delimit a section using 10 dashes", "description": "Delimit a section using 10 dashes",
"body" : "---------- $0" "body": "---------- $0"
}, },
"Typeclass instances": { "Typeclass instances": {
"prefix": "sinstances", "prefix": "sinstances",
"description": "Delimit a section which declares typeclass instances", "description": "Delimit a section which declares typeclass instances",
"body" : ["---------- Typeclass instances", "$0"] "body": ["---------- Typeclass instances", "$0"]
},
"If": {
"prefix": "if",
"description": "If then else expression",
"body": ["if $1", "\tthen $2", "\telse $3"]
} }
} }

View file

@ -88,6 +88,9 @@ main =
("M-g", spawn myBrowser), ("M-g", spawn myBrowser),
("M-d", spawn "Discord"), ("M-d", spawn "Discord"),
("M-v", spawn "alacritty -e vimclip"), ("M-v", spawn "alacritty -e vimclip"),
("M-s", spawn "spectacle -rcb"),
("M-S-s", spawn "spectacle -mcb"),
("M-C-s", spawn "spectacle -ucb"),
("M-c", kill) ("M-c", kill)
] ]

View file

@ -7,33 +7,6 @@
sha256 = "13p3i0b8azkmhafyv8hc4hav1pmgqg52xzvk2a3gp3ppqqx9bwpc"; sha256 = "13p3i0b8azkmhafyv8hc4hav1pmgqg52xzvk2a3gp3ppqqx9bwpc";
}; };
arpeggio = fetchFromGitHub {
owner = "kana";
repo = "vim-arpeggio";
rev = "01c8fc1a72ef58e490ee0490c65ee313b1b6e843";
sha256 = "0405yp1273kzsr3g5j6mj2dfs73qvw716474phkdr67md8ln12dy";
};
agda-nvim = fetchFromGitHub {
owner = "Isti115";
repo = "agda.nvim";
rev = "c7da627547e978b4ac3780af1b8f418c8b12ff98";
sha256 = "0k9g0bqm1a4ivl4cs6f780nnjnc8svc1kqif4l4ahsfzasnj7dbk";
};
idris2-nvim = fetchFromGitHub {
owner = "ShinKage";
repo = "idris2-nvim";
rev = "fdc47ba6f0e9d15c2754ee98b6455acad0fa7c95";
sha256 = "1kzbgmxpywpinrjdrb4crxwlk3jlck3yia2wbl0rq7xwfga663g4";
};
telescope-file-browser-nvim = fetchFromGitHub {
owner = "nvim-telescope";
repo = "telescope-file-browser.nvim";
rev = "ee355b83e00475e11dec82e3ea166f846a392018";
sha256 = "1s39si5fifv6bvjk8kzs2zy18ap5q22pfqg68wn5icnp588498hz";
};
}; };
fishPlugins = { fishPlugins = {
z = fetchFromGitHub { z = fetchFromGitHub {
@ -47,8 +20,8 @@
agnoster = fetchFromGitHub { agnoster = fetchFromGitHub {
owner = "oh-my-fish"; owner = "oh-my-fish";
repo = "theme-agnoster"; repo = "theme-agnoster";
rev = "1ffca413bfbc8941c28982eea97c1e1fa3612d57"; rev = "c142e802983bd1b34b4d91efac2126fc5913126d";
sha256 = "1dvws7mrz8shca6lmnanz72zm7b2cnhg549in655inw0rk9hcbma"; sha256 = "060yydkxmvmlzq2236pjqfmpgvm3g1085c5yzilq0nl1dvmz3wnh";
}; };
harleen = fetchFromGitHub { harleen = fetchFromGitHub {
@ -91,14 +64,14 @@
easy-purescript-nix = fetchFromGitHub { easy-purescript-nix = fetchFromGitHub {
owner = "justinwoo"; owner = "justinwoo";
repo = "easy-purescript-nix"; repo = "easy-purescript-nix";
rev = "0ad5775c1e80cdd952527db2da969982e39ff592"; rev = "3d8b602e80c0fa7d97d7f03cb8e2f8b06967d509";
sha256 = "0x53ads5v8zqsk4r1mfpzf5913byifdpv5shnvxpgw634ifyj1kg"; sha256 = "0kvnsc4j0h8qvv69613781i2qy51rcbmv5ga8j21nsqzy3l8fd9w";
}; };
githubNvimTheme = fetchFromGitHub { githubNvimTheme = fetchFromGitHub {
owner = "projekt0n"; owner = "projekt0n";
repo = "github-nvim-theme"; repo = "github-nvim-theme";
rev = "eeac2e7b2832d8de9a21cfa8627835304c96bb44"; rev = "b3f15193d1733cc4e9c9fe65fbfec329af4bdc2a";
sha256 = "1rfxif39y42amkz772976l14dnsa9ybi2dpkaqbdz7zvwgwm545m"; sha256 = "0vnizbmzf42h3idm35nrcv4g2aigvgmgb80qk5s4xq1513bzrdf0";
}; };
} }