summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlendi <slendi@socopon.com>2023-11-24 01:48:47 +0200
committerSlendi <slendi@socopon.com>2023-11-24 01:48:47 +0200
commit40f219417d6da9230f8310a519ad909ce356ac0a (patch)
tree567b98d15f130cb77f50d3df5e5a1d9787018847
parent037f80fe640717ec1dff49431135d8bbc1f71bbc (diff)
Update neovim config.HEADmaster
Signed-off-by: Slendi <slendi@socopon.com>
-rw-r--r--dotconfig/nvim/lua/slendi/after/init.lua13
-rw-r--r--dotconfig/nvim/lua/slendi/after/lsp.lua5
-rw-r--r--dotconfig/nvim/lua/slendi/after/snippets.lua228
-rw-r--r--dotconfig/nvim/lua/slendi/after/treesitter.lua1
-rw-r--r--dotconfig/nvim/lua/slendi/opt.lua15
-rw-r--r--dotconfig/nvim/lua/slendi/packer.lua11
6 files changed, 272 insertions, 1 deletions
diff --git a/dotconfig/nvim/lua/slendi/after/init.lua b/dotconfig/nvim/lua/slendi/after/init.lua
index 1412130..c4d99d1 100644
--- a/dotconfig/nvim/lua/slendi/after/init.lua
+++ b/dotconfig/nvim/lua/slendi/after/init.lua
@@ -3,3 +3,16 @@ require'slendi.after.telescope'
require'slendi.after.fun'
require'slendi.after.lsp'
require'slendi.after.toggleterm'
+
+vim.cmd[[
+imap <silent><script><expr> <C-J> copilot#Accept("\<CR>")
+let g:copilot_no_tab_map = v:true
+filetype plugin on
+]]
+
+vim.api.nvim_create_autocmd({ 'BufEnter' }, {
+ pattern = '/home/slendi/*',
+ -- you could optionaly replace with
+ -- pattern = vim.fn.expand('~') .. '/dev/*',
+ command = "Copilot enable"
+ })
diff --git a/dotconfig/nvim/lua/slendi/after/lsp.lua b/dotconfig/nvim/lua/slendi/after/lsp.lua
index 25f5979..9f0eb43 100644
--- a/dotconfig/nvim/lua/slendi/after/lsp.lua
+++ b/dotconfig/nvim/lua/slendi/after/lsp.lua
@@ -47,6 +47,8 @@ end
-- luasnip setup
local luasnip = require'luasnip'
+require'slendi.after.snippets'
+
-- nvim-cmp setup
local cmp = require'cmp'
cmp.setup {
@@ -86,6 +88,9 @@ cmp.setup {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
+ window = {
+ documentation = cmp.config.window.bordered()
+ },
}
vim.keymap.set('n', '<Leader>R', '<cmd>lua vim.lsp.buf.rename()<cr>')
diff --git a/dotconfig/nvim/lua/slendi/after/snippets.lua b/dotconfig/nvim/lua/slendi/after/snippets.lua
new file mode 100644
index 0000000..0ab374a
--- /dev/null
+++ b/dotconfig/nvim/lua/slendi/after/snippets.lua
@@ -0,0 +1,228 @@
+local ls = require('luasnip')
+
+require("luasnip.loaders.from_snipmate").lazy_load{
+ path = {
+ "~/.config/nvim/snippets",
+ }
+}
+
+local s = ls.snippet
+local sn = ls.snippet_node
+local t = ls.text_node
+local i = ls.insert_node
+local f = ls.function_node
+local c = ls.choice_node
+local d = ls.dynamic_node
+local r = ls.restore_node
+local l = require("luasnip.extras").lambda
+local rep = require("luasnip.extras").rep
+local p = require("luasnip.extras").partial
+local m = require("luasnip.extras").match
+local n = require("luasnip.extras").nonempty
+local dl = require("luasnip.extras").dynamic_lambda
+local fmt = require("luasnip.extras.fmt").fmt
+local fmta = require("luasnip.extras.fmt").fmta
+local types = require("luasnip.util.types")
+local conds = require("luasnip.extras.expand_conditions")
+
+ls.add_snippets("tex", {
+ ls.parser.parse_snippet("beg", "\\begin{$1}\n\t$2\n\\end{$1}"),
+ ls.parser.parse_snippet("range", '$1_0 ... $1_${2:n}'),
+ ls.parser.parse_snippet("math", '\\[\n\t$1\n\\]'),
+ ls.parser.parse_snippet("frac", "\\frac{$1}{$2}"),
+ ls.parser.parse_snippet("sum", "\\sum_{${1:i}=0}^{${2:n}} $3"),
+ ls.parser.parse_snippet("vec", "\\vec{${1:v}}"),
+ ls.parser.parse_snippet("it", "\\item $1"),
+ ls.parser.parse_snippet("enum", "\\begin{enumerate}\n\t\\item $1\n\\end{enumerate}"),
+ ls.parser.parse_snippet("itemize", "\\begin{itemize}\n\t\\item $1\n\\end{itemize}"),
+ ls.parser.parse_snippet("->", "\\rightarrow"),
+ ls.parser.parse_snippet("=>", "\\Rightarrow"),
+ ls.parser.parse_snippet("=>>", "\\Longrightarrow"),
+ ls.parser.parse_snippet("->>", "\\longrightarrow"),
+ ls.parser.parse_snippet("<-", "\\leftarrow"),
+ ls.parser.parse_snippet("<<=", "\\Longleftarrow"),
+ ls.parser.parse_snippet("<<-", "\\longleftarrow"),
+ ls.parser.parse_snippet("<=>", "\\Leftrightarrow"),
+ ls.parser.parse_snippet("dacasinumaidaca", "\\iff"),
+ ls.parser.parse_snippet("rezulta", "\\implies"),
+
+ ls.parser.parse_snippet("<=", "\\leq"),
+ ls.parser.parse_snippet(">=", "\\geq"),
+
+ ls.parser.parse_snippet("!=", "\\neq"),
+
+ ls.parser.parse_snippet("inf", "\\infty"),
+
+ ls.parser.parse_snippet("lim", "\\lim_{${1:n}\\to${2:0}} $3"),
+ ls.parser.parse_snippet("integral", "\\int_{${1:a}}^{${2:b}} $3"),
+
+ ls.parser.parse_snippet("x", "\\times"),
+
+ ls.parser.parse_snippet("oricare", "\\forall"),
+ ls.parser.parse_snippet("exista", "\\exists"),
+ ls.parser.parse_snippet("nuexista", "\\nexists"),
+ ls.parser.parse_snippet("existaunic", "\\exists!"),
+ ls.parser.parse_snippet("natural", "\\N"),
+ ls.parser.parse_snippet("intreg", "\\Z"),
+ ls.parser.parse_snippet("rationale", "\\Q"),
+ ls.parser.parse_snippet("real", "\\R"),
+ ls.parser.parse_snippet("complex", "\\C"),
+
+ ls.parser.parse_snippet("amare", "\\mathbb{A}"),
+ ls.parser.parse_snippet("bmare", "\\mathbb{B}"),
+ ls.parser.parse_snippet("cmare", "\\mathbb{C}"),
+ ls.parser.parse_snippet("dmare", "\\mathbb{D}"),
+ ls.parser.parse_snippet("emare", "\\mathbb{E}"),
+ ls.parser.parse_snippet("fmare", "\\mathbb{F}"),
+ ls.parser.parse_snippet("gmare", "\\mathbb{G}"),
+ ls.parser.parse_snippet("hmare", "\\mathbb{H}"),
+ ls.parser.parse_snippet("imare", "\\mathbb{I}"),
+ ls.parser.parse_snippet("jmare", "\\mathbb{J}"),
+ ls.parser.parse_snippet("kmare", "\\mathbb{K}"),
+ ls.parser.parse_snippet("lmare", "\\mathbb{L}"),
+ ls.parser.parse_snippet("mmare", "\\mathbb{M}"),
+ ls.parser.parse_snippet("nmare", "\\mathbb{N}"),
+ ls.parser.parse_snippet("omare", "\\mathbb{O}"),
+ ls.parser.parse_snippet("pmare", "\\mathbb{P}"),
+ ls.parser.parse_snippet("qmare", "\\mathbb{Q}"),
+ ls.parser.parse_snippet("rmare", "\\mathbb{R}"),
+ ls.parser.parse_snippet("smare", "\\mathbb{S}"),
+ ls.parser.parse_snippet("tmare", "\\mathbb{T}"),
+ ls.parser.parse_snippet("umare", "\\mathbb{U}"),
+ ls.parser.parse_snippet("vmare", "\\mathbb{V}"),
+ ls.parser.parse_snippet("wmare", "\\mathbb{W}"),
+ ls.parser.parse_snippet("xmare", "\\mathbb{X}"),
+ ls.parser.parse_snippet("ymare", "\\mathbb{Y}"),
+ ls.parser.parse_snippet("zmare", "\\mathbb{Z}"),
+
+ ls.parser.parse_snippet("vid", "\\emptyset"),
+ ls.parser.parse_snippet("nada", "\\emptyset"),
+ ls.parser.parse_snippet("inclus", "\\subset"),
+ ls.parser.parse_snippet("apartine", "\\in"),
+ ls.parser.parse_snippet("floor", "\\lfloor $1 \\rfloor"),
+ ls.parser.parse_snippet("ceil", "\\lceil $1 \\rceil"),
+ ls.parser.parse_snippet("abs", "\\left| $1 \\right|"),
+
+ ls.parser.parse_snippet("alpha", "\\alpha"),
+ ls.parser.parse_snippet("beta", "\\beta"),
+ ls.parser.parse_snippet("gamma", "\\gamma"),
+ ls.parser.parse_snippet("delta", "\\delta"),
+ ls.parser.parse_snippet("epsilon", "\\epsilon"),
+ ls.parser.parse_snippet("varepsilon", "\\varepsilon"),
+ ls.parser.parse_snippet("zeta", "\\zeta"),
+ ls.parser.parse_snippet("eta", "\\eta"),
+ ls.parser.parse_snippet("theta", "\\theta"),
+ ls.parser.parse_snippet("vartheta", "\\vartheta"),
+ ls.parser.parse_snippet("iota", "\\iota"),
+ ls.parser.parse_snippet("kappa", "\\kappa"),
+ ls.parser.parse_snippet("lambda", "\\lambda"),
+ ls.parser.parse_snippet("mu", "\\mu"),
+ ls.parser.parse_snippet("miu", "\\mu"),
+ ls.parser.parse_snippet("nu", "\\nu"),
+ ls.parser.parse_snippet("xi", "\\xi"),
+ ls.parser.parse_snippet("omicron", "\\omicron"),
+ ls.parser.parse_snippet("pi", "\\pi"),
+ ls.parser.parse_snippet("varpi", "\\varpi"),
+ ls.parser.parse_snippet("rho", "\\rho"),
+ ls.parser.parse_snippet("varrho", "\\varrho"),
+ ls.parser.parse_snippet("sigma", "\\sigma"),
+ ls.parser.parse_snippet("varsigma", "\\varsigma"),
+ ls.parser.parse_snippet("tau", "\\tau"),
+ ls.parser.parse_snippet("upsilon", "\\upsilon"),
+ ls.parser.parse_snippet("phi", "\\phi"),
+ ls.parser.parse_snippet("varphi", "\\varphi"),
+ ls.parser.parse_snippet("chi", "\\chi"),
+ ls.parser.parse_snippet("psi", "\\psi"),
+ ls.parser.parse_snippet("omega", "\\omega"),
+
+ ls.parser.parse_snippet("similar", "\\simeq"),
+ ls.parser.parse_snippet("apro", "\\simeq"),
+ ls.parser.parse_snippet("apro2", "\\approx"),
+
+ ls.parser.parse_snippet("obs", "\\obs{\n\t$1\n}"),
+ ls.parser.parse_snippet("def", "\\defn{\n\t$1\n}"),
+
+ ls.parser.parse_snippet("sn", "se numește"),
+
+ ls.parser.parse_snippet("mat4", "\\begin{pmatrix}\n\t$1 & $2 & $3 & $4 \\\\\\\\\n\t$5 & $6 & $7 & $8 \\\\\\\\\n\t$9 & ${10} & ${11} & ${12} \\\\\\\\\n\t${13} & ${14} & ${15} & ${16}\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("mat3", "\\begin{pmatrix}\n\t$1 & $2 & $3 \\\\\\\\\n\t$4 & $5 & $6 \\\\\\\\\n\t$7 & $8 & $9\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("mat2", "\\begin{pmatrix}\n\t$1 & $2 \\\\\\\\\n\t$3 & $4\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("mat4det", "\\begin{vmatrix}\n\t$1 & $2 & $3 & $4 \\\\\\\\\n\t$5 & $6 & $7 & $8 \\\\\\\\\n\t$9 & ${10} & ${11} & ${12} \\\\\\\\\n\t${13} & ${14} & ${15} & ${16}\n\\end{vmatrix}"),
+ ls.parser.parse_snippet("mat3det", "\\begin{vmatrix}\n\t$1 & $2 & $3 \\\\\\\\\n\t$4 & $5 & $6 \\\\\\\\\n\t$7 & $8 & $9\n\\end{vmatrix}"),
+ ls.parser.parse_snippet("mat2det", "\\begin{vmatrix}\n\t$1 & $2 \\\\\\\\\n\t$3 & $4\n\\end{vmatrix}"),
+
+ ls.parser.parse_snippet("mat3range", "\\begin{pmatrix}\n\t$1_0 & $1_1 & $1_2 \\\\\\\\\n\t$1_3 & $1_4 & $1_5 \\\\\n\t$1_6 & $1_7 & $1_8\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("mat2range", "\\begin{pmatrix}\n\t$1_0 & $1_1 \\\\\\\\\n\t$1_2 & $1_3\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("mat3x1range", "\\begin{pmatrix}\n\t$1_0 \\\\\\\\\n\t$1_1 \\\\\\\\\n\t$1_2\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("mat2x1range", "\\begin{pmatrix}\n\t$1_0 \\\\\\\\\n\t$1_1\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("matdefx1range", "\\begin{pmatrix}\n\t$1_0 \\\\\\\\\n\t... \\\\\\\\\n\t$1_${2:n}\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("mat1xdefrange", "\\begin{pmatrix}\n\t$1_0 ... $1_${2:n}\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("mat1x3range", "\\begin{pmatrix}\n\t$1_0 & $1_1 & $1_2\n\\end{pmatrix}"),
+ ls.parser.parse_snippet("mat1x2range", "\\begin{pmatrix}\n\t$1_0 & $1_1\n\\end{pmatrix}"),
+
+ ls.parser.parse_snippet("matb", "\\begin{center}\\[\n\t$1\n\\]\\end{center}"),
+ ls.parser.parse_snippet("msp", "\\msp"),
+
+ ls.parser.parse_snippet("defeq", "\\myeq{def}"),
+
+ s(
+ {trig = "([A-Za-z])([0-9]+)", regTrig = true}, {
+ f(function(_, snip)
+ return snip.captures[1] .. "_" .. snip.captures[2]
+ end)
+ }),
+
+ s( -- This snippets creates the sympy block ;)
+ { trig = "sym", desc = "Creates a sympy block" },
+ fmt("sympy {} sympy{}",
+ { i(1), i(0) }
+ )
+ ),
+
+ s( -- This one evaluates anything inside the simpy block
+ { trig = "sympy.*sympy", regTrig = true, desc = "Sympy block evaluator" },
+ d(1, function(_, parent)
+ -- Gets the part of the block we actually want, and replaces spaces
+ -- at the beginning and at the end
+ local to_eval = string.gsub(parent.trigger, "^sympy(.*)sympy", "%1")
+ to_eval = string.gsub(to_eval, "^%s+(.*)%s+$", "%1")
+
+ local Job = require("plenary.job")
+
+ local sympy_script = string.format(
+ [[
+from sympy import *
+from sympy.parsing.sympy_parser import parse_expr
+from sympy.printing.latex import print_latex
+parsed = parse_expr('%s')
+print_latex(parsed)
+ ]],
+ to_eval
+ )
+
+ sympy_script = string.gsub(sympy_script, "^[\t%s]+", "")
+ local result = ""
+
+ Job:new({
+ command = "python",
+ args = {
+ "-c",
+ sympy_script,
+ },
+ on_exit = function(j)
+ result = j:result()
+ end,
+ }):sync()
+
+ return sn(nil, t(result))
+ end)
+ ),
+
+ s({ trig = "((\\d+)|(\\d*)(\\\\)?([A-Za-z]+)((\\^|_)(\\{\\d+\\}|\\d))*)/", regTrig = true, desc = "Add frac to existing" }, {
+ d(1, function(_, snip)
+ local num = snip.captures[1]
+ return '\\frac{' .. num .. '}{$1}$0'
+ end)
+ }),
+})
+
diff --git a/dotconfig/nvim/lua/slendi/after/treesitter.lua b/dotconfig/nvim/lua/slendi/after/treesitter.lua
index d197a93..ae3fbc3 100644
--- a/dotconfig/nvim/lua/slendi/after/treesitter.lua
+++ b/dotconfig/nvim/lua/slendi/after/treesitter.lua
@@ -5,6 +5,7 @@ require'nvim-treesitter.configs'.setup {
enable = true,
additional_vim_regex_highlighting = false,
},
+ ignore_install = { "latex" },
}
require'treesitter-context'.setup {
trim_scope = 'inner',
diff --git a/dotconfig/nvim/lua/slendi/opt.lua b/dotconfig/nvim/lua/slendi/opt.lua
index fa146f8..3b89b7d 100644
--- a/dotconfig/nvim/lua/slendi/opt.lua
+++ b/dotconfig/nvim/lua/slendi/opt.lua
@@ -11,6 +11,13 @@ vim.o.relativenumber = true
vim.o.scrolloff = 2
+vim.o.spelllang = 'ro,en'
+
+vim.cmd [[
+ setlocal spell
+ inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
+]]
+
-- Tab size
vim.o.tabstop = 2
vim.o.softtabstop = vim.o.tabstop
@@ -61,3 +68,11 @@ vim.cmd [[
set guifont=FiraCode\ Nerd\ Font\ Mono:h12
]]
+
+vim.cmd[[
+let g:tex_flavor = 'latex'
+let g:vimtex_view_method = 'zathura'
+let g:vimtex_quickfix_mode = 0
+set conceallevel=1
+let g:tex_conceal = 'abdmg'
+]]
diff --git a/dotconfig/nvim/lua/slendi/packer.lua b/dotconfig/nvim/lua/slendi/packer.lua
index 7ffd1a5..404cdcd 100644
--- a/dotconfig/nvim/lua/slendi/packer.lua
+++ b/dotconfig/nvim/lua/slendi/packer.lua
@@ -29,6 +29,8 @@ return require'packer'.startup(function(use)
use 'chiedo/vim-case-convert'
+ use 'lervag/vimtex'
+
use {
"mcchrish/zenbones.nvim",
requires = "rktjmp/lush.nvim"
@@ -39,6 +41,8 @@ return require'packer'.startup(function(use)
requires = { 'nvim-tree/nvim-web-devicons', opt = true },
}
+ use 'github/copilot.vim'
+
-- Beautiful code parsing
use 'nvim-treesitter/nvim-treesitter'
use 'nvim-treesitter/playground'
@@ -54,10 +58,15 @@ return require'packer'.startup(function(use)
}
-- LSP BABY
+ use 'hrsh7th/cmp-buffer'
+ use 'hrsh7th/cmp-path'
use 'hrsh7th/nvim-cmp' -- Autocompletion plugin
use 'hrsh7th/cmp-nvim-lsp' -- LSP source for nvim-cmp
+ use {
+ 'L3MON4D3/LuaSnip',
+ run = "make install_jsregexp"
+ } -- Snippets plugin
use 'saadparwaiz1/cmp_luasnip' -- Snippets source for nvim-cmp
- use 'L3MON4D3/LuaSnip' -- Snippets plugin
use 'brymer-meneses/grammar-guard.nvim' -- Useful for typos in text files
use {