diff --git a/dotfiles/neovim/ftplugin/lua.lua b/dotfiles/neovim/ftplugin/lua.lua index 5427c03..8d7cb66 100644 --- a/dotfiles/neovim/ftplugin/lua.lua +++ b/dotfiles/neovim/ftplugin/lua.lua @@ -23,12 +23,3 @@ vim.keymap.set("n", "ls", function() end end, opts("Run .setup() in current file")) -local status, wk = pcall(require, "which-key") - -if status then - wk.register({ - ["l"] = { - name = "Local commands" - } - }) -end diff --git a/dotfiles/neovim/ftplugin/purescript.lua b/dotfiles/neovim/ftplugin/purescript.lua index 5ab7641..ae2e905 100644 --- a/dotfiles/neovim/ftplugin/purescript.lua +++ b/dotfiles/neovim/ftplugin/purescript.lua @@ -1,7 +1,7 @@ local arpeggio = require("my.plugins.arpeggio") local A = require("my.abbreviations") -print("Initializing purescript keybinds...") +-- print("Initializing purescript keybinds...") -- Use vt to test arpeggio.chordSilent("n", "vt", ":VimuxRunCommand \"clear && spago test\"", diff --git a/dotfiles/neovim/ftplugin/tex.lua b/dotfiles/neovim/ftplugin/tex.lua index 6a2d1fd..80d5bc1 100644 --- a/dotfiles/neovim/ftplugin/tex.lua +++ b/dotfiles/neovim/ftplugin/tex.lua @@ -7,8 +7,8 @@ vim.opt.conceallevel = 0 vim.opt.wrap = true vim.g.tex_conceal = "abdmg" --- vim.g.vimtex_syntax_conceal = 1 vim.g.vimtex_imaps_enabled = 0 +-- vim.g.vimtex_syntax_conceal = 1 local abbreviations = { -- Greek chars @@ -28,8 +28,9 @@ local abbreviations = { { "ints", "\\mathbb{I}" }, { "nats", "\\mathbb{N}" }, { "rats", "\\mathbb{Q}" }, - { "rreal", "\\mathbb{R}" }, - { "ffield", "\\mathbb{F}" }, + { "rrea", "\\mathbb{R}" }, + { "ppri", "\\mathbb{P}" }, + { "ffie", "\\mathbb{F}" }, { "ccom", "\\mathbb{C}" }, -- Exponents @@ -109,13 +110,17 @@ local abbreviations = { -- words - { "rref", "reduced row echalon form" } + { "rref", "reduced row echalon form" }, + { "thrf", "therefore" } } local abolishAbbreviations = { - { "egv{a,e}{,s}", "eigenv{alue,ector}{}" }, - { "ib{p,s}", "integration by {parts,substitution}" } + { "eg{va,ve,p}{,s}", "eigen{value,vector,pair}{}" }, + { "ib{p,s}", "integration by {parts,substitution}" }, + { "mx{,s}", "matri{x,ces}" } } A.manyLocalAbbr(abbreviations) AB.abolishMany(abolishAbbreviations) + +vim.keymap.set("n", "lc", "VimtexCompile", { desc = "Compile current buffer using vimtex" }) diff --git a/dotfiles/neovim/lua/my/keymaps.lua b/dotfiles/neovim/lua/my/keymaps.lua index e581745..b712aa4 100644 --- a/dotfiles/neovim/lua/my/keymaps.lua +++ b/dotfiles/neovim/lua/my/keymaps.lua @@ -38,6 +38,17 @@ function M.setup() M.move("Q", "yQ") M.move("", "a", { desc = "Go to previous file" }) + vim.keymap.set({ "n", "v" }, "qn", function() + local buf = vim.api.nvim_win_get_buf(0) + + -- Only save if file is writable + if vim.bo[buf].modifiable and not vim.bo[buf].readonly then + vim.cmd [[write]] + end + + vim.cmd "q" + end, { desc = "Quit current buffer" }) + vim.keymap.set("n", "Q", ":wqa", { desc = "Save all files and quit" }) vim.keymap.set("n", "rw", ":%s//", { desc = "Replace word in file" diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua index eabc966..121ad4b 100644 --- a/dotfiles/neovim/lua/my/plugins/init.lua +++ b/dotfiles/neovim/lua/my/plugins/init.lua @@ -42,12 +42,7 @@ function M.setup() require("my.plugins.hydra").setup() require("my.plugins.clipboard-image").setup() - require("mind").setup({ - persistence = { - state_path = "~/Mind/mind.json", - data_dir = "~/Mind/data" - } - }) + require("my.plugins.mind").setup() -- require("my.plugins.slam").setup() end diff --git a/dotfiles/neovim/lua/my/plugins/mind.lua b/dotfiles/neovim/lua/my/plugins/mind.lua new file mode 100644 index 0000000..e202297 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/mind.lua @@ -0,0 +1,32 @@ +local mind = require("mind") +local M = {} + +function M.setup() + mind.setup({ + persistence = { + state_path = "~/Mind/mind.json", + data_dir = "~/Mind/data" + }, + ui = { + width = 50 + } + }) + + vim.keymap.set("n", "m", function() + local buffers = vim.api.nvim_list_bufs() + local should_open = true + + for _, buf in pairs(buffers) do + if vim.api.nvim_buf_is_loaded(buf) and vim.bo[buf].filetype == "mind" then + should_open = false + vim.cmd("bd " .. buf) + end + end + + if should_open then + mind.open_main() + end + end, { desc = "Toggle mind panel" }) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/telescope.lua b/dotfiles/neovim/lua/my/plugins/telescope.lua index 8de4635..3fbd018 100644 --- a/dotfiles/neovim/lua/my/plugins/telescope.lua +++ b/dotfiles/neovim/lua/my/plugins/telescope.lua @@ -16,6 +16,7 @@ local keybinds = { { "", "find_files", "Find files" }, { "ft", find_files_by_extension("tex"), "Find tex files" }, { "fl", find_files_by_extension("lua"), "Find lua files" }, + { "fp", find_files_by_extension("purs"), "Find purescript files" }, { "d", "diagnostics", "Diagnostics" }, { "", "live_grep", "Search in project" }, { "t", "builtin", "Show builtin pickers" }, diff --git a/dotfiles/neovim/lua/my/plugins/whichkey.lua b/dotfiles/neovim/lua/my/plugins/whichkey.lua index ab8d390..6cc7ffc 100644 --- a/dotfiles/neovim/lua/my/plugins/whichkey.lua +++ b/dotfiles/neovim/lua/my/plugins/whichkey.lua @@ -1,9 +1,17 @@ +local wk = require("which-key") + local M = {} function M.setup() - require("which-key").setup({ + wk.setup({ triggers = { "", "d", "y", "q", "z", "g", "c" } }) + + wk.register({ + ["l"] = { + name = "Local commands" + } + }) end return M diff --git a/dotfiles/vscode-snippets/package.json b/dotfiles/vscode-snippets/package.json index 3800190..a77b117 100644 --- a/dotfiles/vscode-snippets/package.json +++ b/dotfiles/vscode-snippets/package.json @@ -31,6 +31,12 @@ "tex" ], "path": "./snippets/latex/core.json" + }, + { + "language": [ + "lua" + ], + "path": "./snippets/lua/core.json" } ] } diff --git a/dotfiles/vscode-snippets/snippets/lua/core.json b/dotfiles/vscode-snippets/snippets/lua/core.json new file mode 100644 index 0000000..b14c2f6 --- /dev/null +++ b/dotfiles/vscode-snippets/snippets/lua/core.json @@ -0,0 +1,15 @@ +{ + "Lua setup-module": { + "prefix": "msetup", + "description": "Create lua module with setup function inside", + "body": [ + "local M = {}", + "", + "function M.setup()", + " $0", + "end", + "", + "return M" + ] + } +}