diff --git a/dotfiles/neovim/ftplugin/purescript.lua b/dotfiles/neovim/ftplugin/purescript.lua index 04e24c2..62dcb94 100644 --- a/dotfiles/neovim/ftplugin/purescript.lua +++ b/dotfiles/neovim/ftplugin/purescript.lua @@ -1,5 +1,3 @@ -local A = require("my.abbreviations") - -- Use vt to test vim.keymap.set( "n", @@ -17,16 +15,3 @@ vim.keymap.set( ) 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) - - diff --git a/dotfiles/neovim/ftplugin/tex.lua b/dotfiles/neovim/ftplugin/tex.lua index 1104f84..08daa65 100644 --- a/dotfiles/neovim/ftplugin/tex.lua +++ b/dotfiles/neovim/ftplugin/tex.lua @@ -60,6 +60,7 @@ local abbreviations = { { "iin", "\\in" }, { "tto", "\\to" }, { "iip", "\\implies" }, + { "iib", "\\impliedby" }, { "iff", "\\iff" }, { "land", "\\land" }, { "lor", "\\lor" }, @@ -117,6 +118,9 @@ local abolishAbbreviations = { { "dete{,s}", "determinant{}" }, { "ort{n,g}", "orto{normal,gonal}" }, { "l{in,de}", "linearly {independent,dependent}" }, + { "lcon{,s}", "linear combination{}" }, + { "vsm", "\\vecspace" }, -- math vector space + { "vst{,s}", "vector space{,s}" }, -- text vector space -- Graph theory { "vx{,s}", "vert{ex,ices}" }, @@ -210,12 +214,9 @@ local abolishAbbreviations = { local expanded = scrap.expand_many(abolishAbbreviations) --- print("Expanded") A.manyLocalAbbr(abbreviations) A.manyLocalAbbr(expanded) -print(#expanded .. " abbreviations") - vim.keymap.set( "n", "lc", diff --git a/dotfiles/neovim/lazy-lock.json b/dotfiles/neovim/lazy-lock.json index 9071833..4e715d5 100644 --- a/dotfiles/neovim/lazy-lock.json +++ b/dotfiles/neovim/lazy-lock.json @@ -27,6 +27,7 @@ "leap": { "branch": "main", "commit": "f565a9c4d92245d8b619235bebeaa73cc38aa40e" }, "lspkind.nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, "lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" }, + "magma-nvim": { "branch": "main", "commit": "395b48e2e202d82fca76c15d2dcd8785c125d686" }, "mind.nvim": { "branch": "master", "commit": "e59c52758c399caceb549c698cfa2d65e6bbb9f9" }, "neoconf.nvim": { "branch": "main", "commit": "f67013cf18d9db5cc6c3ce2d5a4051bad75fe628" }, "neodev.nvim": { "branch": "main", "commit": "6a2310ef6386e7a5ad5bdc56c844410bf5de8225" }, diff --git a/dotfiles/neovim/lua/my/abbreviations/global.lua b/dotfiles/neovim/lua/my/abbreviations/global.lua new file mode 100644 index 0000000..e67afda --- /dev/null +++ b/dotfiles/neovim/lua/my/abbreviations/global.lua @@ -0,0 +1,34 @@ +local A = require("my.abbreviations") +local scrap = require("scrap") +local M = {} + +M.symols = { + -- Unicode: + { "iin", "∈" }, -- [I]ncluded [i][n] + { "mfrl", "∀" }, -- [M]ath [f]o[r]al[l] + + -- Ascii stuff: + { "tto", "->" }, -- [t]o + { "ffrom", "<-" }, -- [f]rom + { "iip", "=>" }, -- [i]t [i]m[p]lies + { "iib", "<=" }, -- [i]t's [i]mplied [b]ly + + { "leq", "<=" }, -- [l]ess than or [e][q]ual + { "geq", ">=" }, -- [g]reater than or [e][q]ual + { "eq", "=" }, -- [e][q]ual + { "deq", "==" }, -- [d]ouble [e][q]ual + { "land", "/\\" }, -- [l]ogial [a][n][d] + { "lor", "\\/" }, -- [l]ogial [o][r] +} + +M.words = { + { "thrf", "therefore" }, + { "frl", "forall" }, +} + +function M.setup() + A.manyGlobalAbbr(scrap.expand_many(M.words)) + A.manyGlobalAbbr(scrap.expand_many(M.symols, { capitalized = false })) +end + +return M diff --git a/dotfiles/neovim/lua/my/abbreviations.lua b/dotfiles/neovim/lua/my/abbreviations/init.lua similarity index 65% rename from dotfiles/neovim/lua/my/abbreviations.lua rename to dotfiles/neovim/lua/my/abbreviations/init.lua index 919c6fe..5e5e2ae 100644 --- a/dotfiles/neovim/lua/my/abbreviations.lua +++ b/dotfiles/neovim/lua/my/abbreviations/init.lua @@ -16,4 +16,15 @@ function M.abbr(lhs, rhs) vim.cmd(":iabbrev " .. lhs .. " " .. rhs) end +function M.manyGlobalAbbr(abbreviations) + for _, value in pairs(abbreviations) do + M.abbr(value[1], value[2]) + end +end + + +function M.setup() + require("my.abbreviations.global").setup() +end + return M diff --git a/dotfiles/neovim/lua/my/helpers/env.lua b/dotfiles/neovim/lua/my/helpers/env.lua index 56e58d7..2d94302 100644 --- a/dotfiles/neovim/lua/my/helpers/env.lua +++ b/dotfiles/neovim/lua/my/helpers/env.lua @@ -1,6 +1,9 @@ local function makeEnv(cond) return { - active = cond, + -- I am doing this to get type hints! + active = function() + return cond + end, not_active = function() return not cond() end, @@ -36,5 +39,5 @@ return { return makeEnv(function() return a.active() or b.active() end) - end + end, } diff --git a/dotfiles/neovim/lua/my/init.lua b/dotfiles/neovim/lua/my/init.lua index 3886f9b..5acb6be 100644 --- a/dotfiles/neovim/lua/my/init.lua +++ b/dotfiles/neovim/lua/my/init.lua @@ -5,6 +5,7 @@ function M.setup() require("my.options").setup() require('my.keymaps').setup() require('my.lazy').setup() + require('my.abbreviations').setup() end return M diff --git a/dotfiles/neovim/lua/my/plugins/firenvim.lua b/dotfiles/neovim/lua/my/plugins/firenvim.lua index 2148958..a8d3cf8 100644 --- a/dotfiles/neovim/lua/my/plugins/firenvim.lua +++ b/dotfiles/neovim/lua/my/plugins/firenvim.lua @@ -14,6 +14,9 @@ function M.config() }, }, } + + -- Disable status line + vim.opt.laststatus = 0 end return M diff --git a/dotfiles/neovim/lua/my/plugins/lualine.lua b/dotfiles/neovim/lua/my/plugins/lualine.lua index f56246e..160486d 100644 --- a/dotfiles/neovim/lua/my/plugins/lualine.lua +++ b/dotfiles/neovim/lua/my/plugins/lualine.lua @@ -3,7 +3,7 @@ local env = require("my.helpers.env") local M = { "nvim-lualine/lualine.nvim", event = "VeryLazy", - cond = env.vscode.not_active(), + cond = env.vscode.not_active() and env.firenvim.not_active(), } function M.config() diff --git a/dotfiles/neovim/lua/my/plugins/magma.lua b/dotfiles/neovim/lua/my/plugins/magma.lua new file mode 100644 index 0000000..b947147 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/magma.lua @@ -0,0 +1,61 @@ +local M = { + "dccsillag/magma-nvim", + cmd = "MagmaInit", + config = function() + local prefix = "M" + + local status, wk = pcall(require, "which-key") + + if status then + wk.register({ + [prefix] = { + desc = "[M]agma", + }, + }) + end + + vim.keymap.set( + "n", + prefix .. "e", + "MagmaEvaluateOperator", + { expr = true, silent = true, desc = "[E]valuate motion" } + ) + + vim.keymap.set( + "n", + prefix .. "ee", + "MagmaEvaluateLine", + { silent = true, desc = "[E]valuate line" } + ) + + vim.keymap.set( + "n", + prefix .. "r", + "MagmaReevaluateCell", + { silent = true, desc = "[R]e-evaluate cell" } + ) + + vim.keymap.set( + "n", + prefix .. "d", + "MagmaDelete", + { silent = true, desc = "[D]elete cell" } + ) + + vim.keymap.set( + "n", + prefix .. "o", + "MagmaShowOutput", + { silent = true, desc = "Show [o]utput" } + ) + + vim.keymap.set( + "v", + prefix .. "e", + "MagmaEvaluateVisual", + { silent = true, desc = "[E]vluate visual selection" } + ) + end, +} + +return M diff --git a/home/adrielus/features/neovim/default.nix b/home/adrielus/features/neovim/default.nix index 7a4433b..276423a 100644 --- a/home/adrielus/features/neovim/default.nix +++ b/home/adrielus/features/neovim/default.nix @@ -36,6 +36,10 @@ let texlive.combined.scheme-full # Latex stuff python38Packages.pygments # required for latex syntax highlighting + + # Required by magma-nvim: + # python310Packages.pynvim + # python310Packages.jupyter ]; in let