Finish refactoring directory

This commit is contained in:
2024-05-03 18:38:25 +02:00
parent 2ef96e965b
commit 6438e2b385
72 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
column_limit: 120
#indent_width: 4
#use_tab: false
#tab_width: 4
#continuation_indent_width: 4
#spaces_before_call: 1
#keep_simple_control_block_one_line: true
#keep_simple_function_one_line: true
#align_args: true
#break_after_functioncall_lp: false
#break_before_functioncall_rp: false
#spaces_inside_functioncall_parens: false
#spaces_inside_functiondef_parens: false
#align_parameter: true
#chop_down_parameter: false
#break_after_functiondef_lp: false
#break_before_functiondef_rp: false
#align_table_field: true
#break_after_table_lb: true
#break_before_table_rb: true
#chop_down_table: false
#chop_down_kv_table: true
#table_sep: ","
column_table_limit: 1
#extra_sep_at_table_end: false
#spaces_inside_table_braces: false
#break_after_operator: true
#double_quote_to_single_quote: false
#single_quote_to_double_quote: false
#spaces_around_equals_in_field: true
#line_breaks_after_function_body: 1
#line_separator: input

View File

@@ -0,0 +1,38 @@
# neovim config
`neovim` configuration files.
## Usage
1. Install depencencies
* See one of the Dockerfiles in `dockerfiles` for the necessary packages
* Use a patched font (see, e.g., [nerd fonts](https://www.nerdfonts.com/))
2. Clone repository into configuration directory:
```bash
$ git clone ssh://git@git.mercurial-manifold.eu:2224/an.tsouchlos/config-nvim.git ~/.config/nvim
```
3. If desired, configure github copilot by running `:Copilot setup`
## Build docker images
### Arch linux
Because AUR package installation requires the `fakeroot` command, which is
extremely slow when [no limit has been set on the maximum number of file
descriptors](https://github.com/moby/moby/issues/45436), the image has to
be build using the `--ulimit "nofile=1024:1048576"` option:
```bash
$ docker build . -f dockerfiles/Dockerfile.archlinux --ulimit "nofile=1024:1048576" -t config
$ docker run --rm -it config
```
### Ubuntu
Because neovim is installed through an `AppImage`, the container has to be
started with `--privileged` to be able to run `nvim`.
```bash
$ docker build . -f dockerfiles/Dockerfile.ubuntu -t config
$ docker run --rm -it --privileged config
```

View File

@@ -0,0 +1,61 @@
FROM archlinux:latest
#
# General boiler plate
#
# Add mock non-root user for AUR package compilation
RUN useradd --no-create-home --shell=/bin/false build && usermod -L build
RUN echo 'build ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# Ready image for installation
RUN pacman-key --init
RUN pacman-key --populate archlinux
RUN pacman -Sy archlinux-keyring --noconfirm && pacman -Su --noconfirm
RUN pacman -Syu --noconfirm
# Install generic dependencies
RUN pacman -S git wget sudo base-devel --noconfirm
#
# Neovim specific
#
# Install nvim
RUN pacman -S neovim --noconfirm
# Install nvim module dependencies
RUN pacman -S python-pynvim --noconfirm # python3 provider
RUN pacman -S npm --noconfirm # mason requirements
RUN pacman -S fd ripgrep --noconfirm # Telescope requirements
RUN pacman -S powerline-fonts --noconfirm # vim-airline requirements
#RUN pacman -S autopep8 texlive-binextra \
# perl-yaml-tiny perl-file-homedir --noconfirm # neoformat requirements
WORKDIR /tmp
USER build
ARG HOME=/tmp
RUN wget https://aur.archlinux.org/cgit/aur.git/snapshot/neovim-remote.tar.gz
RUN tar xzvf neovim-remote.tar.gz
RUN cd neovim-remote && makepkg -s --noconfirm
USER root
RUN pacman -U neovim-remote/*.pkg.tar.zst --noconfirm # vimtex requirements
WORKDIR /
# Copy configuration
RUN mkdir -p /root/.config/nvim
COPY . /root/.config/nvim

View File

@@ -0,0 +1,96 @@
FROM ubuntu:22.04
#
# General boiler plate
#
# Ready image for installation
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update -y && apt upgrade -y
# Install generic dependencies
RUN apt install git python3 python3-pip sudo -y
# Set up user
ARG UNAME=dev
ARG UID=1000
ARG GID=1000
RUN groupadd -g $GID -o $UNAME
RUN useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
RUN adduser $UNAME sudo
RUN echo "%sudo ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers.d/nopassword
#
# Install neovim
#
# Install neovim
WORKDIR /tmp
RUN git clone https://github.com/neovim/neovim.git
WORKDIR /tmp/neovim
RUN git checkout stable
RUN apt install ninja-build gettext cmake unzip curl -y
RUN make CMAKE_BUILD_TYPE=Release -j `nproc` && make install
WORKDIR /
# Install package dependencies
RUN python3 -m pip install pynvim # python3 provider
RUN python3 -m pip install jupytext # jupytext requirements
RUN apt install fd-find ripgrep -y # Telescope requirements
RUN apt install fonts-powerline -y # vim-airline requirements
RUN python3 -m pip install neovim-remote # vimtex requirements
RUN apt install curl -y # vim-doge requirements
RUN apt install npm python3-venv luarocks -y # mason build requirements
RUN python3 -m pip install cairosvg pnglatex plotly kaleido pyperclip jupyter-client ipykernel # molten requirements
# Configure
RUN mkdir -p "/home/${UNAME}/.config/nvim"
COPY . "/home/${UNAME}/.config/nvim"
RUN chown -R $UNAME:$UNAME "/home/${UNAME}/.config"
USER $UNAME
RUN nvim --headless "+Lazy! sync" +qa
RUN nvim --headless "+MasonInstall clangd pyright cmake-language-server bash-language-server texlab clang-format latexindent mdformat autopep8" +qa
RUN nvim --headless "+TSInstallSync markdown" +qa # For some reason, without this markdown installation fails the first time
USER root
#
# Install other tools
#
# Install firefox
# (Taken from https://askubuntu.com/a/1404401)
RUN apt install software-properties-common -y
RUN add-apt-repository ppa:mozillateam/ppa
RUN echo '\n\
Package: *\n\
Pin: release o=LP-PPA-mozillateam\n\
Pin-Priority: 1001\n\n\
Package: firefox\n\
Pin: version 1:1snap1-0ubuntu2\n\
Pin-Priority: -1\n\
' | tee /etc/apt/preferences.d/mozilla-firefox
RUN apt install firefox -y
RUN echo 'Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";' | tee /etc/apt/apt.conf.d/51unattended-upgrades-firefox
# Other stuff
RUN apt install fzf xclip -y
USER $UNAME
WORKDIR /home/$UNAME
CMD /bin/bash

View File

@@ -0,0 +1,52 @@
FROM ubuntu:22.04
#
# General boiler plate
#
# Ready image for installation
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update -y && apt upgrade -y
# Install generic dependencies
RUN apt install git python3 python3-pip -y
#
# Install neovim
#
# Install neovim
WORKDIR /tmp
RUN git clone https://github.com/neovim/neovim.git
WORKDIR /tmp/neovim
RUN git checkout stable
RUN apt install ninja-build gettext cmake unzip curl -y
RUN make CMAKE_BUILD_TYPE=Release -j `nproc` && make install
WORKDIR /
# Install package dependencies
RUN python3 -m pip install pynvim # python3 provider
RUN python3 -m pip install jupytext # jupytext requirements
RUN apt install fd-find ripgrep -y # Telescope requirements
RUN apt install fonts-powerline -y # vim-airline requirements
RUN python3 -m pip install neovim-remote # vimtex requirements
RUN apt install curl -y # vim-doge requirements
RUN apt install npm python3-venv luarocks -y # mason build requirements
RUN python3 -m pip install cairosvg pnglatex plotly kaleido pyperclip jupyter-client ipykernel # molten requirements
# Configure
RUN mkdir -p /root/.config/nvim
COPY . /root/.config/nvim
RUN nvim --headless "+Lazy! sync" +qa
RUN nvim --headless "+MasonInstall clangd pyright cmake-language-server bash-language-server texlab clang-format latexindent luaformatter mdformat autopep8" +qa
RUN nvim --headless "+TSInstallSync markdown" +qa # For some reason, without this markdown installation fails the first time

View File

@@ -0,0 +1,17 @@
require("set")
require("remap")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins")

View File

@@ -0,0 +1,50 @@
{
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
"auto-session": { "branch": "main", "commit": "9e0a169b6fce8791278abbd110717b921afe634d" },
"cellular-automaton.nvim": { "branch": "main", "commit": "b7d056dab963b5d3f2c560d92937cb51db61cb5b" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"copilot.vim": { "branch": "release", "commit": "1e135c5303bc60598f6314a2276f31dc91aa34dd" },
"dressing.nvim": { "branch": "master", "commit": "5162edb1442a729a885c45455a07e9a89058be2f" },
"friendly-snippets": { "branch": "main", "commit": "d5f74ce4dfdd82848f3f4eac65fe6e29ac5df4c2" },
"gruvbox.nvim": { "branch": "main", "commit": "6e4027ae957cddf7b193adfaec4a8f9e03b4555f" },
"harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" },
"lazy.nvim": { "branch": "main", "commit": "bef521ac89c8d423f9d092e37b58e8af0c099309" },
"lsp-colors.nvim": { "branch": "main", "commit": "2bbe7541747fd339bdd8923fc45631a09bb4f1e5" },
"lsp-zero.nvim": { "branch": "v3.x", "commit": "b93f040edd57888cd6a1e7d9dee47dddc4463f8f" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "273fdde8ac5e51f3a223ba70980e52bbc09d9f6f" },
"mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" },
"molten-nvim": { "branch": "main", "commit": "8346bba69e0de96278dad2038e9be74605908b7d" },
"neoformat": { "branch": "master", "commit": "4372abb846f43ec121df40e620682c985ebc8286" },
"noice.nvim": { "branch": "main", "commit": "0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12" },
"nui.nvim": { "branch": "main", "commit": "cbd2668414331c10039278f558630ed19b93e69b" },
"nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" },
"nvim-dap": { "branch": "master", "commit": "6ae8a14828b0f3bff1721a35a1dfd604b6a933bb" },
"nvim-dap-ui": { "branch": "master", "commit": "5934302d63d1ede12c0b22b6f23518bb183fc972" },
"nvim-lspconfig": { "branch": "master", "commit": "aa5f4f4ee10b2688fb37fa46215672441d5cd5d9" },
"nvim-nio": { "branch": "master", "commit": "d8743224616f8107347ddebc77cdbf1e488bdee2" },
"nvim-tree.lua": { "branch": "master", "commit": "347e1eb35264677f66a79466bb5e3d111968e12c" },
"nvim-treesitter": { "branch": "master", "commit": "9a47a523e3b9e49d3fa14d5743b9860a66eca731" },
"nvim-web-devicons": { "branch": "master", "commit": "794bba734ec95eaff9bb82fbd112473be2087283" },
"overseer.nvim": { "branch": "master", "commit": "89942ad366c8a9bb93f82411de17dc7c644b4e3b" },
"plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" },
"session-lens": { "branch": "main", "commit": "1b65d8e1bcd1836c5135cce118ba18d662a9dabd" },
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
"todo-comments.nvim": { "branch": "main", "commit": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d" },
"toggleterm.nvim": { "branch": "main", "commit": "066cccf48a43553a80a210eb3be89a15d789d6e6" },
"trouble.nvim": { "branch": "main", "commit": "b9cf677f20bb2faa2dacfa870b084e568dca9572" },
"undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" },
"vim-doge": { "branch": "master", "commit": "a96aef58c04e30caf0ce6e98da2e43694624df18" },
"vim-flog": { "branch": "master", "commit": "6289ab2e237ceeefdbcc7eb584b63d144bf88d94" },
"vim-fugitive": { "branch": "master", "commit": "dac8e5c2d85926df92672bf2afb4fc48656d96c7" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"vimtex": { "branch": "master", "commit": "a80934749c69cc6875b3c9b13ef59573a4824fb2" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}

View File

@@ -0,0 +1,11 @@
return {
{
"utilyre/barbecue.nvim",
name = "barbecue",
version = "*",
dependencies = {"SmiteshP/nvim-navic", "nvim-tree/nvim-web-devicons"},
config = function()
require("barbecue").setup()
end,
}
}

View File

@@ -0,0 +1,6 @@
return {
{
"GCBallesteros/jupytext.nvim",
config = true
}
}

View File

@@ -0,0 +1,15 @@
return {
{
"seandewar/killersheep.nvim",
config = function()
require("killersheep").setup {
gore = true, -- Enables/disables blood and gore.
keymaps = {
move_left = "h", -- Keymap to move cannon to the left.
move_right = "l", -- Keymap to move cannon to the right.
shoot = "<Space>" -- Keymap to shoot the cannon.
}
}
end
}
}

View File

@@ -0,0 +1,8 @@
return {
{
"ThePrimeagen/vim-be-good",
cmd = {
"VimBeGood"
}
}
}

View File

@@ -0,0 +1,28 @@
return {
name = "CMake Build",
builder = function()
local file = vim.fn.expand("%:p")
return {
cmd = {
"cmake"
},
args = {
"--build",
"build",
"-j16"
},
components = {
{
"on_output_quickfix"
},
"default"
}
}
end,
condition = {
filetype = {
"cmake",
"cpp"
}
}
}

View File

@@ -0,0 +1,24 @@
return {
name = "CMake Clean",
builder = function()
local file = vim.fn.expand("%:p")
return {
cmd = {
"rm"
},
args = {
"-r",
"build",
},
components = {
"default"
}
}
end,
condition = {
filetype = {
"cmake",
"cpp"
}
}
}

View File

@@ -0,0 +1,58 @@
return {
name = "CMake Generate",
params = {
build_type = {
type = "enum",
choices = {
"Debug",
"Release",
"RelWithDebInfo",
"MinSizeRel"
},
default = "Debug"
},
generator = {
type = "enum",
choices = {
"Ninja",
"Unix Makefiles"
},
default = "Ninja"
},
compiler = {
type = "enum",
choices = {
"g++",
"clang++"
},
default = "g++"
}
},
builder = function(params)
return {
cmd = {
"cmake"
},
args = {
"-B",
"build",
"-S",
".",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DCMAKE_BUILD_TYPE=" .. params.build_type,
"-DCMAKE_CXX_COMPILER=" .. params.compiler,
"-G",
params.generator
},
components = {
"default"
}
}
end,
condition = {
filetype = {
"cmake",
"cpp"
}
}
}

View File

@@ -0,0 +1,27 @@
return {
name = "CMake Test",
builder = function()
return {
cmd = {
"ctest"
},
args = {
"--test-dir",
"build",
"--output-on-failure",
},
components = {
{
"on_output_quickfix"
},
"default"
}
}
end,
condition = {
filetype = {
"cmake",
"cpp"
}
}
}

View File

@@ -0,0 +1,22 @@
return {
name = "Python Run",
builder = function()
local file = vim.fn.expand("%:p")
return {
cmd = {
"python"
},
args = {
file
},
components = {
"default"
}
}
end,
condition = {
filetype = {
"python"
}
}
}

View File

@@ -0,0 +1,73 @@
-------------------
-- Helper functions
-------------------
local function clamp(x, min, max) return math.max(math.min(x, max), min) end
local function get_random_image()
images = {
{
[[██╗ █████╗ ██████╗██╗ ██╗███████╗]],
[[██║ ██╔══██╗██╔════╝██║ ██║██╔════╝]],
[[██║ ███████║██║ ███████║███████╗]],
[[██║ ██╔══██║██║ ██╔══██║╚════██║]],
[[███████╗██║ ██║╚██████╗██║ ██║███████║]],
[[╚══════╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝]]
},
{
[[ ,,,╓▄▄▓▓▓▓▄ ,▄▓∩]],
[[ ,╓▄▄▄▄▓▓▓▓▓▓▓▓▀▓▓▓▓▓▓▓▓▓▀▀▀▓@@æ▄╓,▄▄ ,▄▓▓▓▓ ]],
[[ ,▄▄▓▓█████▀╫╫Ñ▒Ñ▒▒▒▒░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒▀▀▀▓@#▓▓▀▓▓▓Ñ ]],
[[ -2▓╫▒▒▒▒▒╫▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▓▓▓ ]],
[[ ª╨╩Ñ▒▒▒▒▒╫▄▒▒▒▒▒▒▒░░▒▒▒▒▒▒▒▒▒░▒░░░░░░░═╨` `╫╫▓▓▓▓ ]],
[[ `ªº╩▒▒▒▒░░░░...░░▒▒▒▄▒▒▒ºª`` `▀▓▓▓ ]],
[[ ╙▓µ ]]
},
{
[[███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗]],
[[████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║]],
[[██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║]],
[[██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║]],
[[██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║]],
[[╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝]]
}
}
local i = 3
math.randomseed(os.time())
if math.fmod(math.random(100), 5) == 0 then
if math.random(0, 1) == 0 then
i = 1
else
i = 2
end
end
return images[i]
end
-----------------
-- Configurtation
-----------------
return {
{
"goolord/alpha-nvim",
lazy = false,
config = function()
local dashboard = require("alpha.themes.dashboard")
dashboard.section.header.val = get_random_image()
dashboard.section.buttons.val = {
dashboard.button('n', ' New file', ':ene <BAR> startinsert <CR>'),
dashboard.button('r', ' Recent files', ':Telescope oldfiles <CR>'),
dashboard.button('f', '󰥨 Find file', ':Telescope find_files <CR>'),
dashboard.button('g', '󰱼 Find text', ':Telescope live_grep <CR>'),
dashboard.button('p', ' Open project', ':Telescope session-lens search_session<CR>'),
dashboard.button('l', '󰒲 Lazy', ':Lazy<CR>'),
dashboard.button('q', ' Quit', ':qa<CR>')
}
require("alpha").setup(dashboard.opts)
end
}
}

View File

@@ -0,0 +1,44 @@
return {
{
"rmagatti/auto-session",
dependencies = {
"nvim-lualine/lualine.nvim"
},
event = "VimEnter",
init = function()
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
vim.keymap.set('n', '<leader>ss', '<cmd>SessionSave<CR>', {
desc = "Save"
})
vim.keymap.set('n', '<leader>sd', '<cmd>SessionDelete<CR>', {
desc = "Delete"
})
end,
opts = {
log_level = "error",
auto_save_enabled = false
}
},
{
'rmagatti/session-lens',
cmd = {
"Autosession",
"SearchSession"
},
dependencies = {
'rmagatti/auto-session',
'nvim-telescope/telescope.nvim'
},
init = function()
vim.keymap.set('n', '<leader>sf', function() require('session-lens').search_session() end, {
desc = "Find"
})
end,
config = function()
require('session-lens').setup({
prompt_title = 'Sessions'
})
end
}
}

View File

@@ -0,0 +1,9 @@
return {
{
'Eandrju/cellular-automaton.nvim',
cmd = {
"CellularAutomaton"
},
init = function() vim.keymap.set("n", "<leader>fu", "<cmd>CellularAutomaton make_it_rain<CR>") end
}
}

View File

@@ -0,0 +1,20 @@
return {
{
"github/copilot.vim",
event = {
"BufReadPost",
"BufNewFile"
},
cmd = {
"Copilot"
},
init = function()
vim.g.copilot_no_tab_map = true
vim.g.copilot_assume_mapped = true
vim.api.nvim_set_keymap("i", "<C-y>", 'copilot#Accept("<CR>")', {
silent = true,
expr = true
})
end
}
}

View File

@@ -0,0 +1,154 @@
return {
{
'mfussenegger/nvim-dap',
config = function()
local dap = require("dap")
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = {
"-i",
"dap"
}
}
dap.adapters.python = function(cb, config)
if config.request == 'attach' then
local port = (config.connect or config).port
local host = (config.connect or config).host or '127.0.0.1'
cb({
type = 'server',
port = assert(port, '`connect.port` is required for a python `attach` configuration'),
host = host,
options = {
source_filetype = 'python'
}
})
else
cb({
type = 'executable',
command = 'python',
args = {
'-m',
'debugpy.adapter'
},
options = {
source_filetype = 'python'
}
})
end
end
dap.configurations.c = {
{
name = "Launch",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false
}
}
dap.configurations.cpp = {
{
name = "Launch",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false
}
}
dap.configurations.python = {
{
type = 'python',
request = 'launch',
name = "Launch file",
program = "${file}",
pythonPath = function()
local cwd = vim.fn.getcwd()
if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
return cwd .. '/venv/bin/python'
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
return cwd .. '/.venv/bin/python'
else
return '/usr/bin/python'
end
end
}
}
vim.keymap.set("n", "<leader>db", "<cmd>DapToggleBreakpoint<cr>", {
desc = "Toggle breakpoint"
})
vim.keymap.set("n", "<leader>dc", "<cmd>DapContinue<cr>", {
desc = "Continue"
})
vim.keymap.set("n", "<leader>dt", "<cmd>DapTerminate<cr>", {
desc = "Terminate"
})
vim.keymap.set("n", "<leader>di", "<cmd>DapStepInto<cr>", {
desc = "Step into"
})
vim.keymap.set("n", "<leader>dn", "<cmd>DapStepOver<cr>", {
desc = "Step over"
})
vim.keymap.set("n", "<leader>do", "<cmd>DapStepOut<cr>", {
desc = "Step out"
})
vim.keymap.set("n", '<Leader>dh', function() require('dap.ui.widgets').hover() end, {
desc = "Hover"
})
end
},
{
"rcarriga/nvim-dap-ui",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio"
},
config = function()
require("dapui").setup({
controls = {
enabled = false
},
layouts = {
{
elements = {
{
id = "scopes",
size = 0.33
},
{
id = "breakpoints",
size = 0.33
},
{
id = "stacks",
size = 0.33
}
},
position = "left",
size = 60
},
{
elements = {
{
id = "repl",
size = 1
}
},
position = "bottom",
size = 15
}
}
})
vim.keymap.set("n", "<leader>du", function() require("dapui").toggle() end, {
desc = " Toggle UI"
})
end
}
}

View File

@@ -0,0 +1,15 @@
return {
{
'kkoomen/vim-doge',
build = ':call doge#install()',
init = function()
vim.g.doge_enable_mappings = 0
vim.g.doge_doc_standard_cpp = 'doxygen_cpp_comment_slash'
vim.g.doge_mapping_comment_jump_forward = '<c-j>'
vim.g.doge_mapping_comment_jump_backward = '<c-k>'
vim.keymap.set('n', '<leader>gd', '<Plug>(doge-generate)', { silent = true, desc = "Generate doc"})
-- nmap <silent> <Leader>d <Plug>(doge-generate)
end
}
}

View File

@@ -0,0 +1,6 @@
return {
{
'stevearc/dressing.nvim',
event = 'VimEnter'
}
}

View File

@@ -0,0 +1,22 @@
return {
{
'tpope/vim-fugitive',
cmd = {
"Git"
},
init = function() vim.keymap.set("n", "<leader>gs", vim.cmd.Git) end
},
{
'rbong/vim-flog',
cmd = {
"Flog",
"Floggit",
"Flogsplit"
},
dependencies = {
{
'tpope/vim-fugitive'
}
}
}
}

View File

@@ -0,0 +1,21 @@
return {
{
"ThePrimeagen/harpoon",
-- branch = "harpoon2",
dependencies = {
{
"nvim-lua/plenary.nvim"
}
},
init = function()
vim.keymap.set("n", "<C-e>", function() require("harpoon.ui").toggle_quick_menu() end, {desc = "Toggle harpoon ui"})
vim.keymap.set("n", "<leader>a", function() require("harpoon.mark").add_file() end, {desc = "Add to harpoon list"})
vim.keymap.set("n", "<C-h>", function() require("harpoon.ui").nav_file(1) end)
vim.keymap.set("n", "<C-t>", function() require("harpoon.ui").nav_file(2) end)
vim.keymap.set("n", "<C-n>", function() require("harpoon.ui").nav_file(3) end)
vim.keymap.set("n", "<C-s>", function() require("harpoon.ui").nav_file(4) end)
end
}
}

View File

@@ -0,0 +1,6 @@
return {
{
"folke/lazy.nvim",
tag = "stable"
}
}

View File

@@ -0,0 +1,189 @@
return {
{
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v3.x',
lazy = true,
config = false,
init = function()
-- Disable automatic setup, we are doing it manually
vim.g.lsp_zero_extend_cmp = 0
vim.g.lsp_zero_extend_lspconfig = 0
end
},
{
'williamboman/mason.nvim',
lazy = false,
config = true
},
-- Autocompletion
{
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
dependencies = {
'L3MON4D3/LuaSnip',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-nvim-lsp-signature-help',
'saadparwaiz1/cmp_luasnip'
},
config = function()
local lsp_zero = require('lsp-zero')
lsp_zero.extend_cmp()
local cmp = require('cmp')
cmp.setup({
sources = {
-- LuaFormatter off
{ name = 'path' },
{ name = 'nvim_lsp' },
{ name = 'nvim_lua' },
{ name = 'luasnip', keyword_length = 2 },
{ name = 'buffer', keyword_length = 3 },
{ name = 'nvim_lsp_signature_help' }
-- LuaFormatter on
},
formatting = lsp_zero.cmp_format(),
mapping = cmp.mapping.preset.insert({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<Tab>'] = cmp.mapping.confirm({
select = true
}),
['<C-Space>'] = cmp.mapping.complete()
}),
snippet = {
expand = function(args) require('luasnip').lsp_expand(args.body) end
}
})
cmp.setup.filetype('gitcommit', {
-- LuaFormatter off
sources = cmp.config.sources(
{ { name = 'git' } },
{ { name = 'buffer' } }
)
-- LuaFormatter on
})
cmp.setup.cmdline({
'/',
'?'
}, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{
name = 'buffer'
}
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{
name = 'path'
}
}, {
{
name = 'cmdline'
}
})
})
end
},
-- LSP
{
'neovim/nvim-lspconfig',
cmd = {
'LspInfo',
'LspInstall',
'LspStart'
},
event = {
'BufReadPre',
'BufNewFile'
},
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'williamboman/mason-lspconfig.nvim',
"folke/trouble.nvim"
},
config = function()
local lsp_zero = require('lsp-zero')
lsp_zero.extend_lspconfig()
lsp_zero.on_attach(function(client, bufnr)
vim.keymap.set("n", "<leader>ld", function() vim.lsp.buf.definition() end, {
desc = "Go to definition"
})
vim.keymap.set("n", "<leader>lh", function() vim.lsp.buf.hover() end, {
desc = "Hover"
})
vim.keymap.set("n", "<leader>lr", ":Trouble lsp_references<CR>", {
desc = "Show references"
})
vim.keymap.set("n", "<leader>ln", function() vim.lsp.buf.rename() end, {
desc = "Rename"
})
vim.keymap.set("n", "<leader>ls", function() vim.lsp.buf.signature_help() end, {
desc = "Signature help"
})
vim.keymap.set("n", "<leader>la", function() vim.lsp.buf.code_action() end, {
desc = "Code actions"
})
vim.keymap.set("n", "<leader>la", function() vim.lsp.buf.code_action() end, {
desc = "Code actions"
})
end)
require('mason-lspconfig').setup({
ensure_installed = {
'clangd',
'pyright',
'cmake',
'texlab'
},
handlers = {
lsp_zero.default_setup,
lua_ls = function()
local lua_opts = lsp_zero.nvim_lua_ls()
require('lspconfig').lua_ls.setup(lua_opts)
end
}
})
require('lspconfig')['clangd'].setup {
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--completion-style=bundled",
"--cross-file-rename",
"--header-insertion=iwyu",
-- Required for embedded system compilers
"--query-driver=/**/*g++",
"--offset-encoding=utf-16"
-- "-j=8",
-- "--malloc-trim",
-- "--pch-storage=memory"
}
}
require('lspconfig').matlab_ls.setup({
settings = {
filetypes = {"matlab"},
matlab = {
installPath = "/opt/matlab/R2023a/"
},
},
single_file_support = true
})
end
}
}
}

View File

@@ -0,0 +1,21 @@
return {
{
'nvim-lualine/lualine.nvim',
event = "VimEnter",
dependencies = {
'nvim-tree/nvim-web-devicons'
},
opts = {
options = {
theme = 'gruvbox_dark'
},
extensions = {
'nvim-tree',
'trouble',
'mason',
'lazy',
'toggleterm'
}
}
}
}

View File

@@ -0,0 +1,48 @@
return {
{
"L3MON4D3/LuaSnip",
dependencies = {
{
'rafamadriz/friendly-snippets'
}
},
version = "v2.*",
build = "make install_jsregexp",
event = {
"InsertEnter"
},
init = function()
vim.keymap.set({
"i"
}, "<c-j>", function() require("luasnip").expand() end, {
silent = true
})
vim.keymap.set({
"i",
"s"
}, "<c-j>", function() require("luasnip").jump(1) end, {
silent = true
})
vim.keymap.set({
"i",
"s"
}, "<c-k>", function() require("luasnip").jump(-1) end, {
silent = true
})
end,
config = function()
local loader = require("luasnip.loaders.from_lua")
loader.lazy_load({
paths = {
"./snippets"
}
})
require("luasnip").config.set_config({
enable_autosnippets = true,
store_selection_keys = "<leader>v"
})
end
}
}

View File

@@ -0,0 +1,15 @@
return {
{
"iamcco/markdown-preview.nvim",
cmd = {
"MarkdownPreviewToggle",
"MarkdownPreview",
"MarkdownPreviewStop"
},
ft = {
"markdown"
},
build = function() vim.fn["mkdp#util#install"]() end
}
}

View File

@@ -0,0 +1,33 @@
return {
{
"benlubas/molten-nvim",
build = ":UpdateRemotePlugins",
version = "v1.7.0",
init = function()
vim.keymap.set("n", "<localleader>mi", ":MoltenInit<CR>", {
silent = true,
desc = "Initialize the plugin"
})
vim.keymap.set("n", "<localleader>e", ":MoltenEvaluateOperator<CR>", {
silent = true,
desc = "run operator selection"
})
vim.keymap.set("n", "<localleader>rl", ":MoltenEvaluateLine<CR>", {
silent = true,
desc = "evaluate line"
})
vim.keymap.set("n", "<localleader>rr", ":MoltenReevaluateCell<CR>", {
silent = true,
desc = "re-evaluate cell"
})
vim.keymap.set("v", "<localleader>r", ":<C-u>MoltenEvaluateVisual<CR>gv", {
silent = true,
desc = "evaluate visual selection"
})
vim.g.molten_auto_open_output = false
vim.g.molten_virt_text_output = true
vim.g.molten_virt_text_max_lines = 32
end
}
}

View File

@@ -0,0 +1,37 @@
return {
{
'sbdchd/neoformat',
event = {
"BufReadPost",
"BufNewFile"
},
init = function()
vim.cmd([[
let g:neoformat_enabled_python = ['autopep8']
let g:neoformat_enabled_cpp = ['clangformat']
let g:neoformat_enabled_c = ['clangformat']
let g:neoformat_enable_lua = ['luaformatter']
let g:neoformat_enabled_cmake = ['cmakeformat']
let g:neoformat_markdown_mdformat = {
\ 'exe': 'mdformat',
\ 'args': ['--wrap=79'],
\ 'replace': 1,
\ }
let g:neoformat_enabled_markdown = ['mdformat']
let g:neoformat_enabled_latex = ['latexindent']
let g:latexindent_opt="-m -l -g=/dev/null"
]])
vim.api.nvim_set_keymap('n', '<M-L>', '<cmd>Neoformat<cr>', {
noremap = true,
silent = true
})
vim.api.nvim_set_keymap('i', '<M-L>', '<cmd>Neoformat<cr>', {
noremap = true,
silent = true
})
end
}
}

View File

@@ -0,0 +1,38 @@
-- lazy.nvim
return {
"folke/noice.nvim",
event = "VeryLazy",
opts = {
lsp = {
signature = {
enabled = false
},
hover = {
enabled = false
}
},
views = {
cmdline_popup = {
backend = "popup",
relative = "editor",
position = {
row = -1,
col = "0%"
},
border = {
style = "none"
}
},
cmdline_popupmenu = {
relative = "editor",
position = {
row = -2,
col = "0%"
}
}
}
},
dependencies = {
"MunifTanjim/nui.nvim"
}
}

View File

@@ -0,0 +1,18 @@
return {
{
'nvim-tree/nvim-tree.lua',
cmd = {
"NvimTreeToggle",
"NvimTreeFocus"
},
init = function()
vim.opt.termguicolors = true
vim.keymap.set('n', '<leader>e', '<cmd>NvimTreeToggle<cr>', {
noremap = true,
silent = true,
desc = "Explorer"
})
end,
config = function() require("nvim-tree").setup() end
}
}

View File

@@ -0,0 +1,28 @@
return {
"stevearc/overseer.nvim",
config = function()
require("overseer").setup({
templates = {
"builtin",
"user.cmake_generate",
"user.cmake_build",
"user.cmake_clean",
"user.cmake_test",
"user.python_run"
}
})
vim.keymap.set("n", "<leader>oo", function() require("overseer").toggle() end, {
desc = "Toggle"
})
vim.keymap.set("n", "<leader>or", ":OverseerRun<CR>", {
desc = "Run"
})
vim.keymap.set("n", "<leader>oq", ":OverseerQuickAction<CR>", {
desc = "Quick Action"
})
vim.keymap.set("n", "<leader>of", ":OverseerQuickAction open float<CR>", {
desc = "Open Float"
})
end
}

View File

@@ -0,0 +1,6 @@
return {
{
"tpope/vim-surround",
event = "InsertEnter"
}
}

View File

@@ -0,0 +1,50 @@
-- -----------------
-- -- Helper Functions
-- -------------------
-- -- If in a git repo, execute the given function with the option
-- -- "cwd=<git root>". Otherwise, execute the function with no options.
-- local function execute_in_repo_root(func)
-- local function is_git_repo()
-- vim.fn.system("git rev-parse --is-inside-work-tree")
--
-- return vim.v.shell_error == 0
-- end
--
-- local function get_git_root()
-- local dot_git_path = vim.fn.finddir(".git", ".;")
-- return vim.fn.fnamemodify(dot_git_path, ":h")
-- end
--
-- local opts = {}
--
-- if is_git_repo() then opts = {cwd = get_git_root()} end
--
-- func(opts)
-- end
-----------------------
-- Plugin Configuration
-----------------------
return {
{
'nvim-telescope/telescope.nvim',
version = '0.1.5',
dependencies = {
{
'nvim-lua/plenary.nvim'
}
},
cmd = "Telescope",
init = function()
-- LuaFormatter off
vim.keymap.set('n', '<leader>ff', function() require("telescope.builtin").find_files() end,{desc = "Files"})
vim.keymap.set('n', '<leader>fg', function() require("telescope.builtin").live_grep() end,{desc = "grep"})
vim.keymap.set('n', '<leader>fa', function()
require("telescope.builtin").find_files({hidden = true})
end, {desc = "All files"})
vim.keymap.set('n', '<leader>fb', function() require("telescope.builtin").buffers() end, {desc = "Buffers"})
vim.keymap.set('n', '<leader>fh', function() require("telescope.builtin").help_tags() end, {desc = "Help tags"})
-- LuaFormatter on
end
}
}

View File

@@ -0,0 +1,63 @@
return {
-- {'doums/darcula', config = function() vim.cmd('colorscheme darcula') end}
-- {
-- "folke/tokyonight.nvim",
-- lazy = false,
-- priority = 1000,
-- opts = {},
-- config = function() vim.cmd('colorscheme tokyonight-moon') end
-- }
-- {
-- 'rose-pine/neovim',
-- config = function()
-- vim.cmd('colorscheme rose-pine-moon')
-- -- LuaFormatter off
-- vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
-- vim.api.nvim_set_hl(0, "FloatBorder", { bg = "none", fg = "none" })
-- vim.api.nvim_set_hl(0, "TelescopeNormal", { bg = "none" })
-- vim.api.nvim_set_hl(0, "TelescopeBorder", { bg = "none" })
-- -- LuaFormatter on
-- end
-- }
-- {
-- 'AlexvZyl/nordic.nvim',
-- lazy = false,
-- priority = 1000,
-- init = function()
-- require('nordic').setup {
-- telescope = {
-- style = 'classic'
-- -- style = 'flat'
-- }
-- }
-- require'nordic'.load()
-- end
-- }
-- {
-- "briones-gabriel/darcula-solid.nvim",
-- dependencies = "rktjmp/lush.nvim",
-- config = function()
-- vim.cmd 'colorscheme darcula-solid'
-- vim.cmd 'set termguicolors'
-- end
-- }
{
"ellisonleao/gruvbox.nvim",
priority = 1000,
config = true,
opts = {
contrast = "hard"
},
init = function()
vim.cmd("colorscheme gruvbox")
-- LuaFormatter off
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
vim.api.nvim_set_hl(0, "NoiceCmdlineIcon", { bg = "#1d2021" })
vim.api.nvim_set_hl(0, "NoiceCmdlinePopupBorder", { bg = "#1d2021" })
vim.api.nvim_set_hl(0, "NoiceCmdlinePopupTitle", { bg = "#1d2021" })
-- LuaFormatter on
end
}
}

View File

@@ -0,0 +1,9 @@
return {
{
"folke/todo-comments.nvim",
dependencies = {
"nvim-lua/plenary.nvim"
},
opts = {}
}
}

View File

@@ -0,0 +1,21 @@
return {
{
"akinsho/toggleterm.nvim",
version = '*',
opts = {
size = 30,
open_mapping = [[<c-\>]]
},
cmd = {
"ToggleTerm",
"TermExec",
"ToggleTermToggleAll",
"ToggleTermSendCurrentLine",
"ToggleTermSendVisualLines",
"ToggleTermSendVisualSelection"
},
keys = {
[[<c-\>]]
}
}
}

View File

@@ -0,0 +1,42 @@
return {
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
event = {
"BufReadPost",
"BufNewFile"
},
cmd = {
"TSInstall",
"TSBufEnable",
"TSBufDisable",
"TSModuleInfo",
"TSInstallSync"
},
config = function(_, opts)
require("nvim-treesitter.configs").setup({
ensure_installed = {
"cpp",
"c",
"lua",
"vim",
"vimdoc",
"query"
},
sync_install = false,
auto_install = true,
highlight = {
enable = true,
-- additional_vim_regex_highlighting = false,
-- disable = {
-- "latex"
-- },
additional_vim_regex_highlighting = {
"latex"
}
}
})
end
}
}

View File

@@ -0,0 +1,59 @@
return {
{
"folke/trouble.nvim",
dependencies = {
{
"nvim-tree/nvim-web-devicons"
},
{
'folke/lsp-colors.nvim'
},
{
'nvim-telescope/telescope.nvim'
}
},
cmd = {
"Trouble",
"TroubleClose",
"TroubleToggle",
"TroubleRefresh"
},
init = function()
vim.keymap.set("n", "<leader>xx", function() require("trouble").toggle() end, {
desc = "Toggle"
})
vim.keymap.set("n", "<leader>xw", function() require("trouble").toggle("workspace_diagnostics") end, {
desc = "Workspace diagnostics"
})
vim.keymap.set("n", "<leader>xd", function() require("trouble").toggle("document_diagnostics") end, {
desc = "Document diagnostics"
})
vim.keymap.set("n", "<leader>xq", function() require("trouble").toggle("quickfix") end, {
desc = "Quickfix"
})
vim.keymap.set("n", "<leader>xl", function() require("trouble").toggle("loclist") end, {
desc = "Loclist"
})
-- vim.keymap.set("n", "<leader>xr", function() require("trouble").toggle("lsp_references") end, {
-- desc = "LSP references"
-- })
end,
config = function()
local trouble_provider = require("trouble.providers.telescope")
local telescope = require("telescope")
telescope.setup {
defaults = {
mappings = {
i = {
["<c-t>"] = trouble_provider.open_with_trouble
},
n = {
["<c-t>"] = trouble_provider.open_with_trouble
}
}
}
}
end
}
}

View File

@@ -0,0 +1,17 @@
return {
{
'mbbill/undotree',
cmd = {
"UndotreeToggle",
"UndotreeHide",
"UndotreeShow",
"UndotreeFocus",
"UndotreePersistUndo"
},
init = function()
vim.keymap.set("n", "<leader>u", "<cmd>UndotreeToggle<CR>", {
desc = "Undotree"
})
end
}
}

View File

@@ -0,0 +1,63 @@
return {
{
"lervag/vimtex",
ft = {
"tex",
"bib"
},
config = function()
-- General configuration
vim.cmd("syntax enable")
vim.g.vimtex_compiler_latexmk = {
out_dir = 'build',
options = {
'-shell-escape',
'-verbose',
'-file-line-error',
'-interaction=nonstopmode',
'-synctex=1'
}
}
vim.g.vimtex_view_general_viewer = 'sioyek'
vim.g.vimtex_quickfix_mode = 0
-- Concealment
vim.cmd([[set conceallevel=1]])
vim.cmd([[
let g:vimtex_syntax_conceal = {
\ 'accents': 1,
\ 'ligatures': 1,
\ 'cites': 1,
\ 'fancy': 1,
\ 'spacing': 0,
\ 'greek': 1,
\ 'math_bounds': 1,
\ 'math_delimiters': 1,
\ 'math_fracs': 1,
\ 'math_super_sub': 0,
\ 'math_symbols': 1,
\ 'sections': 0,
\ 'styles': 0,
\}
let g:vimtex_syntax_custom_cmds = [
\ {'name': 'bm', 'mathmode': 1, 'argstyle': 'bold', 'conceal': 1},
\]
]])
-- Synctex configuration
vim.g.vimtex_compiler_progname = 'nvr'
local options = string.format(
'--reuse-window --inverse-search="nvr --servername %s +%%2 %%1" --forward-search-file @tex --forward-search-line @line @pdf',
vim.v.servername)
local command = string.format("let g:vimtex_view_general_options='%s'", options)
vim.cmd(command)
end
}
}

View File

@@ -0,0 +1,42 @@
return {
{
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
defaults = {
["<leader>x"] = {
name = "+Trouble"
}
}
},
config = function()
local wk = require("which-key")
wk.register({
["<leader>"] = {
l = {
name = "+LSP"
},
x = {
name = "+Trouble"
},
o = {
name = "+Overseer"
},
d = {
name = "+Debug"
},
f = {
name = "+Find"
},
s = {
name = "+Session"
},
}
})
end
}
}

View File

@@ -0,0 +1,23 @@
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("n", "<C-x>", "<C-w>c")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
vim.keymap.set("x", "<leader>p", "\"_dP")
vim.keymap.set("n", "<leader>d", "\"_d")
vim.keymap.set("v", "<leader>d", "\"_d")
vim.keymap.set("n", "<leader>y", "\"+y")
vim.keymap.set("v", "<leader>y", "\"+y")
vim.keymap.set("n", "<leader>Y", "\"+Y")
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "q:", "<nop>")
vim.cmd [[call nvim_create_user_command('W', 'w', {'nargs': 0})]]
-- vim.keymap.set("n", "<leader>cb", [[:up | %bd | e#<CR>]])

View File

@@ -0,0 +1,28 @@
vim.g.mapleader = " "
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.wrap = false
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.updatetime = 50

View File

@@ -0,0 +1,83 @@
----------------
-- Abbreviations
----------------
local ls = require("luasnip")
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 d = ls.dynamic_node
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local rep = require("luasnip.extras").rep
local line_begin = require("luasnip.extras.expand_conditions").line_begin
-----------
-- Snippets
-----------
return {
s({trig="()", wordTrig=false, snippetType="autosnippet"},
{
t("("),
i(1),
t(")"),
i(0),
}
),
s({trig="[]", wordTrig=false, snippetType="autosnippet"},
{
t("["),
i(1),
t("]"),
i(0),
}
),
s({trig="{}", wordTrig=false, snippetType="autosnippet"},
{
t("{"),
i(1),
t("}"),
i(0),
}
),
s({trig="<>", wordTrig=false, snippetType="autosnippet"},
{
t("<"),
i(1),
t(">"),
i(0),
}
),
s({trig="\"\"", wordTrig=false, snippetType="autosnippet"},
{
t("\""),
i(1),
t("\""),
i(0),
}
),
s({trig="''", wordTrig=false, snippetType="autosnippet"},
{
t("'"),
i(1),
t("'"),
i(0),
}
),
} -- return

View File

@@ -0,0 +1,245 @@
----------------
-- Abbreviations
----------------
local ls = require("luasnip")
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 d = ls.dynamic_node
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local rep = require("luasnip.extras").rep
local line_begin = require("luasnip.extras.expand_conditions").line_begin
---------------
-- Environments
---------------
local tex_utils = {}
tex_utils.in_mathzone = function() -- math context detection
return vim.fn['vimtex#syntax#in_mathzone']() == 1
end
tex_utils.in_text = function()
return not tex_utils.in_mathzone()
end
tex_utils.in_comment = function() -- comment detection
return vim.fn['vimtex#syntax#in_comment']() == 1
end
tex_utils.in_env = function(name) -- generic environment detection
local is_inside = vim.fn['vimtex#env#is_inside'](name)
return (is_inside[1] > 0 and is_inside[2] > 0)
end
local get_visual = function(args, parent)
if (#parent.snippet.env.LS_SELECT_RAW > 0) then
return sn(nil, i(1, parent.snippet.env.LS_SELECT_RAW))
else
return sn(nil, i(1))
end
end
-----------
-- Snippets
-----------
return {
s({trig="notes"},
fmta(
[[
\documentclass[dvipsnames]{article}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mleftright}
\usepackage{bm}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\title{<>}
\author{<>}
\date{<>}
\begin{document}
\maketitle
<>
\end{document}
]],
{
i(1, "Notes"),
i(2, "Andreas Tsouchlos"),
i(3, os.date("%d.%m.%y")),
i(0),
}
)
),
s({trig="beg"},
fmta(
[[
\begin{<>}
<>
\end{<>}
]],
{
i(1),
i(2),
rep(1),
}
)
),
s({trig="sec"},
fmta(
[[
\section{<>}
\label{sec:<>}
]],
{
i(1),
rep(1),
}
)
),
s({trig="ssec"},
fmta(
[[
\subsection{<>}
\label{subsec:<>}
]],
{
i(1),
rep(1),
}
)
),
s({trig="sssec"},
fmta(
[[
\subsubsection{<>}
\label{subsubsec:<>}
]],
{
i(1),
rep(1),
}
)
),
s({trig="csec"},
fmta(
[[
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{<>}
\label{sec:<>}
]],
{
i(1),
rep(1),
}
)
),
s({trig="cssec"},
fmta(
[[
%%%%%%%%%%%%%%%%
\subsection{<>}
\label{subsec:<>}
]],
{
i(1),
rep(1),
}
)
),
s({trig="csssec"},
fmta(
[[
%%%%%%%%
\subsubsection{<>}
\label{subsubsec:<>}
]],
{
i(1),
rep(1),
}
)
),
-- s({trig="()", wordTrig=false, snippetType="autosnippet"},
-- {
-- t("("),
-- i(1),
-- t(")"),
-- i(0),
-- }
-- ),
--
-- s({trig="[]", wordTrig=false, snippetType="autosnippet"},
-- {
-- t("["),
-- i(1),
-- t("]"),
-- i(0),
-- }
-- ),
--
-- s({trig="{}", wordTrig=false, snippetType="autosnippet"},
-- {
-- t("{"),
-- i(1),
-- t("}"),
-- i(0),
-- }
-- ),
--
-- s({trig="<>", wordTrig=false, snippetType="autosnippet"},
-- {
-- t("<"),
-- i(1),
-- t(">"),
-- i(0),
-- }
-- ),
--
-- s({trig="\"\"", wordTrig=false, snippetType="autosnippet"},
-- {
-- t("\""),
-- i(1),
-- t("\""),
-- i(0),
-- }
-- ),
--
-- s({trig="''", wordTrig=false, snippetType="autosnippet"},
-- {
-- t("'"),
-- i(1),
-- t("'"),
-- i(0),
-- }
-- ),
} -- return

View File

@@ -0,0 +1,439 @@
----------------
-- Abbreviations
----------------
local ls = require("luasnip")
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 d = ls.dynamic_node
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local rep = require("luasnip.extras").rep
---------------
-- Environments
---------------
local tex_utils = {}
tex_utils.in_mathzone = function() -- math context detection
return vim.fn['vimtex#syntax#in_mathzone']() == 1
end
tex_utils.in_text = function()
return not tex_utils.in_mathzone()
end
tex_utils.in_comment = function() -- comment detection
return vim.fn['vimtex#syntax#in_comment']() == 1
end
tex_utils.in_env = function(name) -- generic environment detection
local is_inside = vim.fn['vimtex#env#is_inside'](name)
return (is_inside[1] > 0 and is_inside[2] > 0)
end
local get_visual = function(args, parent)
if (#parent.snippet.env.LS_SELECT_RAW > 0) then
return sn(nil, i(1, parent.snippet.env.LS_SELECT_RAW))
else
return sn(nil, i(1))
end
end
-----------
-- Snippets
-----------
return {
s({trig="´a", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\alpha ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´b", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\beta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´g", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\gamma ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´d", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\delta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´e", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\epsilon ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´z", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\zeta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´h", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\eta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´q", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\theta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´i", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\iota ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´k", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\kappa ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´l", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\lambda ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´m", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\mu ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´n", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\nu ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´x", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\xi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´p", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\pi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´r", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\rho ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´s", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\sigma ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´t", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\tau ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´u", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\upsilon ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´f", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\phi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´c", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\chi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´y", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\psi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´w", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\omega ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´A", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Alpha ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´B", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Beta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´G", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Gamma ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´D", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Delta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´E", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Epsilon ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´Z", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Zeta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´H", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Eta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´Q", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Theta ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´I", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Iota ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´K", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Kappa ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´L", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Lambda ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´M", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Mu ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´N", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Nu ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´X", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Xi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´P", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Pi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´R", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Rho ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´S", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Sigma ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´T", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Tau ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´U", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Upsilon ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´F", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Phi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´C", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Chi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´Y", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Psi ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="´W", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Omega ]],
{}
),
{condition = tex_utils.in_mathzone}
),
-- Strictly speaking not greek characters, but very similar snippets
s({trig="´6", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\partial ]],
{}
),
{condition = tex_utils.in_mathzone}
),
} -- return

View File

@@ -0,0 +1,402 @@
----------------
-- Abbreviations
----------------
local ls = require("luasnip")
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 d = ls.dynamic_node
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local rep = require("luasnip.extras").rep
---------------
-- Environments
---------------
local tex_utils = {}
tex_utils.in_mathzone = function() -- math context detection
return vim.fn['vimtex#syntax#in_mathzone']() == 1
end
tex_utils.in_text = function()
return not tex_utils.in_mathzone()
end
tex_utils.in_comment = function() -- comment detection
return vim.fn['vimtex#syntax#in_comment']() == 1
end
tex_utils.in_env = function(name) -- generic environment detection
local is_inside = vim.fn['vimtex#env#is_inside'](name)
return (is_inside[1] > 0 and is_inside[2] > 0)
end
local get_visual = function(args, parent)
if (#parent.snippet.env.LS_SELECT_RAW > 0) then
return sn(nil, i(1, parent.snippet.env.LS_SELECT_RAW))
else
return sn(nil, i(1))
end
end
-----------
-- Snippets
-----------
return {
s({trig="ali", snippetType="autosnippet"},
fmta(
[[
\begin{align*}
<>
<>%
\end{align*}
]],
{
i(0),
i(1, "."),
}
)
),
s({trig="cases"},
fmta(
[[
\begin{cases}
<>
\end{cases}
]],
{
i(0),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="matb"},
fmta(
[[
\begin{bmatrix}
<>
\end{bmatrix}
]],
{
i(0),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="matp"},
fmta(
[[
\begin{pmatrix}
<>
\end{pmatrix}
]],
{
i(0),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig='([^%a])int', regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\int_{<>}^{<>} <> d<> ]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1, "-\\infty"),
i(2, "\\infty"),
i(4),
i(3, "x"),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig='([^%a])prod', regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\prod_{<>}^{<>} ]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1, "-\\infty"),
i(2, "\\infty"),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig='([^%a])sum', regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\sum_{<>}^{<>} ]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1, "n=0"),
i(2, "N-1"),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig='([^%a])sqrt', regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\sqrt{<>} ]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig='([^%a])log', regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\log_{<>} ]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1, "2"),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig='([^%a])ln', regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\ln ]],
{
f( function(_, snip) return snip.captures[1] end ),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig = '([^%a])ff', regTrig = true, wordTrig = false, snippetType = "autosnippet"},
fmta(
[[<>\frac{<>}{<>} ]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1),
i(2)
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([^%a])mcal", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\mathcal{<>}]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([^%a])mbb", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\mathbb{<>}]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([^%a])tt", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\text{<>}]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig=".", snippetType="autosnippet"},
fmta(
[[\cdot ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="$$", snippetType="autosnippet"},
fmta(
[[$<>$]],
{
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([^%a])bm", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\bm{<>}]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="__", wordTrig=false, snippetType="autosnippet"},
fmta(
[[_{<>}]],
{
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="^^", wordTrig=false, snippetType="autosnippet"},
fmta(
[[^{<>}]],
{
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([^%a])oo", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\infty]],
{
f( function(_, snip) return snip.captures[1] end ),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="((", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\mleft( <> \mright)]],
{
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="[[", wordTrig=false, snippetType="autosnippet"},
fmta(
"\\mleft[ <> \\mright]",
{
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="{{", wordTrig=false, snippetType="autosnippet"},
fmta(
"\\mleft\\{ <> \\mright\\}",
{
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="||", wordTrig=false, snippetType="autosnippet"},
fmta(
"\\lvert <> \\rvert ",
{
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([^%a])hat", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\hat{<>}]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([^%a])tld", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\tilde{<>}]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([^%a])bar", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\overline{<>}]],
{
f( function(_, snip) return snip.captures[1] end ),
i(1),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([%a])([%d])", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>_<>]],
{
f( function(_, snip) return snip.captures[1] end ),
f( function(_, snip) return snip.captures[2] end ),
}
),
{condition = tex_utils.in_mathzone}
),
s({trig="=>", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\Rightarrow ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="->", wordTrig=false, snippetType="autosnippet"},
fmta(
[[\rightarrow ]],
{}
),
{condition = tex_utils.in_mathzone}
),
s({trig="([^%a])nab", regTrig=true, wordTrig=false, snippetType="autosnippet"},
fmta(
[[<>\nabla ]],
{
f( function(_, snip) return snip.captures[1] end ),
}
),
{condition = tex_utils.in_mathzone}
),
} -- return

View File

@@ -0,0 +1,132 @@
----------------
-- Abbreviations
----------------
local ls = require("luasnip")
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 d = ls.dynamic_node
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local rep = require("luasnip.extras").rep
---------------
-- Environments
---------------
local tex_utils = {}
tex_utils.in_mathzone = function() -- math context detection
return vim.fn['vimtex#syntax#in_mathzone']() == 1
end
tex_utils.in_text = function()
return not tex_utils.in_mathzone()
end
tex_utils.in_comment = function() -- comment detection
return vim.fn['vimtex#syntax#in_comment']() == 1
end
tex_utils.in_env = function(name) -- generic environment detection
local is_inside = vim.fn['vimtex#env#is_inside'](name)
return (is_inside[1] > 0 and is_inside[2] > 0)
end
local get_visual = function(args, parent)
if (#parent.snippet.env.LS_SELECT_RAW > 0) then
return sn(nil, i(1, parent.snippet.env.LS_SELECT_RAW))
else
return sn(nil, i(1))
end
end
-----------
-- Snippets
-----------
return {
s({trig="funcplot"},
fmta(
[[
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
domain=<>,
width=\textwidth,
height=0.75\textwidth,
]
\addplot+[mark=none, line width=1pt]
{<>};
\end{axis}
\end{tikzpicture}
\end{figure}
]],
{
i(1, "-5:5"),
i(2),
}
)
),
s({trig="csvplot"},
fmta(
[[
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
width=\textwidth,
height=0.75\textwidth,
]
\addplot+[mark=none, line width=1pt]
table[col sep=comma, x=<>, y=<>]
{<>};
\end{axis}
\end{tikzpicture}
\end{figure}
]],
{
i(1, "x"),
i(2, "y"),
i(3),
}
)
),
s({trig="fig"},
fmta(
[[
\begin{figure}[H]
\centering
<>
\caption{<>}
\label{fig:<>}
\end{figure}
]],
{
i(0),
i(1),
i(2),
}
)
),
} -- return