neovim new config
This commit is contained in:
parent
763bbf5cc1
commit
315e988734
50 changed files with 739 additions and 52 deletions
9
home/afoucaultc/packages/neovim/config/colorscheme.nix
Normal file
9
home/afoucaultc/packages/neovim/config/colorscheme.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
colorschemes.tokyonight = {
|
||||
enable = true;
|
||||
settings.style = "night";
|
||||
};
|
||||
};
|
||||
}
|
||||
24
home/afoucaultc/packages/neovim/config/extrafiles.nix
Normal file
24
home/afoucaultc/packages/neovim/config/extrafiles.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# fichiers lua bruts
|
||||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
extraFiles = {
|
||||
# lua
|
||||
"lua/conf/settings.lua".source = ../lua/settings.lua;
|
||||
"lua/conf/lsp-config.lua".source = ../lua/lsp-config.lua;
|
||||
"lua/conf/remap.lua".source = ../lua/remap.lua;
|
||||
"lua/conf/autocmd.lua".source = ../lua/autocmd.lua;
|
||||
# snippets
|
||||
"luasnippets/tex.lua".source = ../snippets/tex.lua;
|
||||
"luasnippets/matlab.lua".source = ../snippets/matlab.lua;
|
||||
};
|
||||
extraConfigLua = ''
|
||||
require("conf.settings")
|
||||
require("conf.lsp-config")
|
||||
require("conf.remap")
|
||||
require("conf.autocmd")
|
||||
require("luasnip.loaders.from_lua").load()
|
||||
'';
|
||||
};
|
||||
|
||||
}
|
||||
25
home/afoucaultc/packages/neovim/config/extrapackages.nix
Normal file
25
home/afoucaultc/packages/neovim/config/extrapackages.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# binaires nécessaires
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
extraPackages = with pkgs; [
|
||||
# lsp
|
||||
nil # nix
|
||||
lua-language-server # lua
|
||||
texlab # latx
|
||||
python3 # python
|
||||
pyright # python v2
|
||||
|
||||
# formatters
|
||||
nixfmt-rfc-style
|
||||
stylua
|
||||
ruff
|
||||
|
||||
# tools
|
||||
zathura
|
||||
ripgrep
|
||||
fd
|
||||
octave
|
||||
];
|
||||
};
|
||||
}
|
||||
18
home/afoucaultc/packages/neovim/config/extraplugins.nix
Normal file
18
home/afoucaultc/packages/neovim/config/extraplugins.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# plugins non implémentés dans nixvim et/ou nixpkgs
|
||||
{ ... }:
|
||||
{
|
||||
# extraPlugins = [
|
||||
# HORS NIXVIM
|
||||
# pkgs.vimPlugins."<plugin name>"
|
||||
# HORS NIXPKGS
|
||||
#(pkgs.vimUtils.buildVimPlugin {
|
||||
# name = "myPlugin";
|
||||
# src = pkgs.fetchFromGitHub {
|
||||
# owner = "<owner>";
|
||||
# repo = "<repo>";
|
||||
# rev = "<commit hash>";
|
||||
# hash = "<nix NAR hash>";
|
||||
# };
|
||||
#})
|
||||
#];
|
||||
}
|
||||
10
home/afoucaultc/packages/neovim/config/globals.nix
Normal file
10
home/afoucaultc/packages/neovim/config/globals.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# configuration vim.g.*
|
||||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
globals = {
|
||||
mapleader = " ";
|
||||
maplocalleader = ",";
|
||||
};
|
||||
};
|
||||
}
|
||||
7
home/afoucaultc/packages/neovim/config/keymaps.nix
Normal file
7
home/afoucaultc/packages/neovim/config/keymaps.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
keymaps = [
|
||||
];
|
||||
};
|
||||
}
|
||||
17
home/afoucaultc/packages/neovim/config/plugins.nix
Normal file
17
home/afoucaultc/packages/neovim/config/plugins.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
../plugins/blink-cmp.nix
|
||||
../plugins/conform-nvim.nix
|
||||
../plugins/gitsigns.nix
|
||||
../plugins/lsp.nix
|
||||
../plugins/lualine.nix
|
||||
../plugins/luasnip.nix
|
||||
../plugins/mini.nix
|
||||
../plugins/oil.nix
|
||||
../plugins/telescope.nix
|
||||
../plugins/treesitter.nix
|
||||
../plugins/vimtex.nix
|
||||
../plugins/which-key.nix
|
||||
];
|
||||
}
|
||||
48
home/afoucaultc/packages/neovim/lua/autocmd.lua
Normal file
48
home/afoucaultc/packages/neovim/lua/autocmd.lua
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
-- (.config/nvim/lua/neoconf/autocmd.lua)
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ async = false })
|
||||
end,
|
||||
})
|
||||
|
||||
local function run_curr_python_file()
|
||||
-- Get file name in the current buffer
|
||||
local file_name = vim.api.nvim_buf_get_name(0)
|
||||
|
||||
-- Get terminal codes for running python file
|
||||
-- ("i" to enter insert before typing rest of the command)
|
||||
local py_cmd = vim.api.nvim_replace_termcodes('ipython "' .. file_name .. '"<cr>', true, false, true)
|
||||
|
||||
-- Determine terminal window split and launch terminal
|
||||
local percent_of_win = 0.4
|
||||
local curr_win_height = vim.api.nvim_win_get_height(0) -- Current window height
|
||||
local term_height = math.floor(curr_win_height * percent_of_win) -- Terminal height
|
||||
vim.cmd(":below " .. term_height .. "split | term") -- Launch terminal (horizontal split)
|
||||
|
||||
-- Press keys to run python command on current file
|
||||
vim.api.nvim_feedkeys(py_cmd, "t", false)
|
||||
end
|
||||
|
||||
vim.keymap.set({ "n" }, "<A-r>", "", {
|
||||
desc = "Run .py file via Neovim built-in terminal",
|
||||
callback = run_curr_python_file,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "markdown", "rmd" },
|
||||
callback = function()
|
||||
-- Force syntaxe markdown
|
||||
vim.bo.syntax = "markdown"
|
||||
-- Conceal normal pour markdown
|
||||
vim.wo.conceallevel = 2
|
||||
-- Désactive vimtex pour ces fichiers
|
||||
vim.b.vimtex_syntax_enabled = 0
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
pcall(vim.treesitter.start)
|
||||
end,
|
||||
})
|
||||
14
home/afoucaultc/packages/neovim/lua/lsp-config.lua
Normal file
14
home/afoucaultc/packages/neovim/lua/lsp-config.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
-- diagnostic
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
prefix = "●", -- Icône avant le message
|
||||
source = "if_many", -- Affiche la source LSP si plusieurs
|
||||
format = function(diag)
|
||||
return string.format("%s: %s", diag.source, diag.message)
|
||||
end,
|
||||
},
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false, -- Évite flicker en insert
|
||||
severity_sort = true,
|
||||
})
|
||||
60
home/afoucaultc/packages/neovim/lua/remap.lua
Normal file
60
home/afoucaultc/packages/neovim/lua/remap.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
-- (.config/nvim/lua/neoconf/remap.lua)
|
||||
-- leader = space
|
||||
-- C = ctrl
|
||||
-- clear highlights when typing esc
|
||||
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
|
||||
-- diagnostic keymaps
|
||||
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
|
||||
-- exit terminal mode (or ctrl C)
|
||||
vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
|
||||
-- disable arrow keys
|
||||
vim.keymap.set("n", "<left>", '<cmd>echo "Use h to move!!"<CR>')
|
||||
vim.keymap.set("n", "<right>", '<cmd>echo "Use l to move!!"<CR>')
|
||||
vim.keymap.set("n", "<up>", '<cmd>echo "Use k to move!!"<CR>')
|
||||
vim.keymap.set("n", "<down>", '<cmd>echo "Use j to move!!"<CR>')
|
||||
-- ctrl hjkl for moving between windows
|
||||
vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
|
||||
vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
|
||||
vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
|
||||
vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
|
||||
-- telescope
|
||||
local builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
|
||||
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Telescope live grep" })
|
||||
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
|
||||
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Telescope help tags" })
|
||||
-- oil
|
||||
vim.keymap.set("n", "<leader>n", "<cmd>Oil<CR>", { desc = "Launch oil buffer" })
|
||||
-- python
|
||||
vim.keymap.set("n", "<F5>", ":w<CR>:!python3 %<CR>", { noremap = true, silent = false })
|
||||
|
||||
-- spell checker from fr to en
|
||||
vim.keymap.set("n", "<leader>sf", function()
|
||||
if vim.o.spelllang == "fr" then
|
||||
vim.o.spelllang = "en"
|
||||
else
|
||||
vim.o.spelllang = "fr"
|
||||
end
|
||||
vim.o.spell = true
|
||||
print("Spelllang: " .. vim.o.spelllang)
|
||||
end, { desc = "Toggle spelllang FR/EN" })
|
||||
-- toggle correction
|
||||
vim.keymap.set("n", "<leader>sg", function()
|
||||
vim.wo.spell = not vim.wo.spell
|
||||
vim.notify("Spell: " .. (vim.wo.spell and "ON" or "OFF"), vim.log.levels.INFO)
|
||||
end, { desc = "Toggle spell check" })
|
||||
|
||||
vim.api.nvim_create_user_command("OctaveRun", function()
|
||||
vim.cmd("write")
|
||||
vim.cmd('!octave -qf "%:p"')
|
||||
end, {})
|
||||
|
||||
-- set vimtex main to current file
|
||||
local function vimtex_set_main()
|
||||
vim.b.vimtex_main = vim.fn.expand("%:p")
|
||||
vim.b.vimtex = nil
|
||||
vim.fn["vimtex#init"]()
|
||||
print("VimTeX main → " .. vim.b.vimtex_main)
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lm", vimtex_set_main, { desc = "VimTeX: set main to current file" })
|
||||
46
home/afoucaultc/packages/neovim/lua/settings.lua
Normal file
46
home/afoucaultc/packages/neovim/lua/settings.lua
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
-- .config/nvim/lua/neoconf/settings.lua
|
||||
vim.g.have_nerd_font = true
|
||||
-- options
|
||||
-- enable line number
|
||||
vim.o.number = true
|
||||
-- relative line number
|
||||
vim.o.relativenumber = true
|
||||
-- dont show the mode
|
||||
vim.o.showmode = true
|
||||
-- sync clipboard
|
||||
vim.schedule(function()
|
||||
vim.o.clipboard = "unnamedplus"
|
||||
end)
|
||||
-- enable break indent
|
||||
vim.o.breakindent = true
|
||||
-- indent options
|
||||
vim.o.autoindent = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.expandtab = true
|
||||
-- save undo history
|
||||
vim.o.undofile = true
|
||||
-- case insensitive search
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
-- keep signcolumn
|
||||
vim.o.signcolumn = "yes"
|
||||
-- config new split opening
|
||||
vim.o.splitright = true
|
||||
vim.o.splitbelow = true
|
||||
-- whitespace char display
|
||||
vim.o.list = true
|
||||
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
|
||||
-- preview substitutions live with !
|
||||
vim.o.inccommand = "split"
|
||||
-- show line cursor
|
||||
vim.o.cursorline = true
|
||||
-- min lines above and below cursor
|
||||
vim.o.scrolloff = 10
|
||||
-- confirm save/confirm
|
||||
vim.o.confirm = true
|
||||
-- spell checking
|
||||
vim.opt.spell = true
|
||||
vim.opt.spelllang = "fr"
|
||||
-- wrap
|
||||
vim.o.wrap = true
|
||||
vim.o.linebreak = true
|
||||
27
home/afoucaultc/packages/neovim/neovim.nix
Normal file
27
home/afoucaultc/packages/neovim/neovim.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{ inputs, ... }:
|
||||
let
|
||||
nixvim = import (
|
||||
builtins.fetchGit {
|
||||
url = "https://github.com/nix-community/nixvim";
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
inputs.nixvim.homeModules.nixvim
|
||||
./config/colorscheme.nix
|
||||
./config/extrafiles.nix
|
||||
./config/extrapackages.nix
|
||||
./config/extraplugins.nix
|
||||
./config/globals.nix
|
||||
./config/keymaps.nix
|
||||
./config/plugins.nix
|
||||
];
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
};
|
||||
}
|
||||
19
home/afoucaultc/packages/neovim/plugins/blink-cmp.nix
Normal file
19
home/afoucaultc/packages/neovim/plugins/blink-cmp.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
blink-cmp = {
|
||||
enable = true;
|
||||
settings = {
|
||||
keymap.preset = "default";
|
||||
sources.default = [
|
||||
"lsp"
|
||||
"path"
|
||||
"snippets"
|
||||
"buffer"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
15
home/afoucaultc/packages/neovim/plugins/conform-nvim.nix
Normal file
15
home/afoucaultc/packages/neovim/plugins/conform-nvim.nix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
conform-nvim = {
|
||||
enable = true;
|
||||
settings.formatters_by_ft = {
|
||||
nix = [ "nixfmt" ];
|
||||
lua = [ "stylua" ];
|
||||
python = [ "ruff_format" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
10
home/afoucaultc/packages/neovim/plugins/gitsigns.nix
Normal file
10
home/afoucaultc/packages/neovim/plugins/gitsigns.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
gitsigns = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
19
home/afoucaultc/packages/neovim/plugins/lsp.nix
Normal file
19
home/afoucaultc/packages/neovim/plugins/lsp.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers = {
|
||||
nil_ls.enable = true;
|
||||
lua-ls = {
|
||||
enable = true;
|
||||
settings.Lua.diagnostics.globals = [ "vim" ];
|
||||
};
|
||||
texlab.enable = true;
|
||||
pyright.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
10
home/afoucaultc/packages/neovim/plugins/lualine.nix
Normal file
10
home/afoucaultc/packages/neovim/plugins/lualine.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
lualine = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
10
home/afoucaultc/packages/neovim/plugins/luasnip.nix
Normal file
10
home/afoucaultc/packages/neovim/plugins/luasnip.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
luasnip = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
10
home/afoucaultc/packages/neovim/plugins/mini.nix
Normal file
10
home/afoucaultc/packages/neovim/plugins/mini.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
mini = {
|
||||
modules.ai = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
11
home/afoucaultc/packages/neovim/plugins/oil.nix
Normal file
11
home/afoucaultc/packages/neovim/plugins/oil.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
oil = {
|
||||
enable = true;
|
||||
settings.default_file_explorer = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
10
home/afoucaultc/packages/neovim/plugins/telescope.nix
Normal file
10
home/afoucaultc/packages/neovim/plugins/telescope.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
telescope = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
20
home/afoucaultc/packages/neovim/plugins/treesitter.nix
Normal file
20
home/afoucaultc/packages/neovim/plugins/treesitter.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
treesitter = {
|
||||
enable = true;
|
||||
settings.ensure_installed = [
|
||||
"nix"
|
||||
"lua"
|
||||
"python"
|
||||
"latex"
|
||||
"vim"
|
||||
"vimdoc"
|
||||
"markdown_inline"
|
||||
"regex"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
16
home/afoucaultc/packages/neovim/plugins/vimtex.nix
Normal file
16
home/afoucaultc/packages/neovim/plugins/vimtex.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
programs.nixvim.plugins.vimtex = {
|
||||
enable = true;
|
||||
autoLoad = true;
|
||||
settings = {
|
||||
view_method = "zathura";
|
||||
complete_close_brace = 1;
|
||||
format_enabled = 1;
|
||||
imaps_enabled = 0;
|
||||
complete_enabled = 0;
|
||||
syntax_enabled = 0;
|
||||
compiler_latexmk.aux_dir = "${config.home.homeDirectory}/.aux-tex/";
|
||||
};
|
||||
};
|
||||
}
|
||||
10
home/afoucaultc/packages/neovim/plugins/which-key.nix
Normal file
10
home/afoucaultc/packages/neovim/plugins/which-key.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins = {
|
||||
which-key = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
11
home/afoucaultc/packages/neovim/snippets/matlab.lua
Normal file
11
home/afoucaultc/packages/neovim/snippets/matlab.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
local ls = require("luasnip")
|
||||
local i = ls.insert_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
return {
|
||||
ls.snippet(
|
||||
{ trig = "plot", name = "Plot", condition = line_begin },
|
||||
fmt([[plot({},{},'Color',{},'Linewidth',1.5,'MarkerSize',0,'DisplayName',"{}")]], { i(1), i(2), i(3), i(4) })
|
||||
),
|
||||
}
|
||||
144
home/afoucaultc/packages/neovim/snippets/tex.lua
Normal file
144
home/afoucaultc/packages/neovim/snippets/tex.lua
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local rep = require("luasnip.extras").rep
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
return {
|
||||
-- ============== Figures ==============
|
||||
s(
|
||||
{ trig = "svgfig", name = "Figures from inkscape PDF+PDF_tex", condition = line_begin },
|
||||
fmt(
|
||||
[[
|
||||
\begin{{figure}}[htbp]
|
||||
\centering
|
||||
\def\svgwidth{{0.99\textwidth}}
|
||||
\import{{figures/{}.pdf_tex}}
|
||||
\caption{{{}}}
|
||||
\label{{{}}}
|
||||
\end{{figure}}
|
||||
]],
|
||||
{ i(1), i(2), rep(1) }
|
||||
)
|
||||
),
|
||||
|
||||
s(
|
||||
{ trig = "sfig", name = "Single figure", condition = line_begin },
|
||||
fmt(
|
||||
[[
|
||||
\begin{{figure}}[htbp]
|
||||
\centering
|
||||
\input{{figures/{}}}
|
||||
\caption{{{}}}
|
||||
\label{{{}}}
|
||||
\end{{figure}}
|
||||
]],
|
||||
{ i(1), i(2), rep(1) }
|
||||
)
|
||||
),
|
||||
|
||||
s(
|
||||
{ trig = "dfig", name = "Double figures", condition = line_begin },
|
||||
fmt(
|
||||
[[
|
||||
\begin{{figure}}
|
||||
\begin{{subfigure}}{{\dfigsize}}
|
||||
\centering
|
||||
\includegraphics[width=\textwidth]{{figures/{}}}
|
||||
\caption{{{}}}
|
||||
\label{{fig:{}}}
|
||||
\end{{subfigure}}
|
||||
\hfill
|
||||
\begin{{subfigure}}{{\dfigsize}}
|
||||
\centering
|
||||
\includegraphics[width=\textwidth]{{figures/{}}}
|
||||
\caption{{{}}}
|
||||
\label{{fig:{}}}
|
||||
\end{{subfigure}}
|
||||
\caption{{{}}}
|
||||
\end{{figure}}
|
||||
]],
|
||||
{ i(2), i(1), rep(2), i(4), i(3), rep(4), i(5) }
|
||||
)
|
||||
),
|
||||
|
||||
s(
|
||||
{ trig = "tab", name = "Table", condition = line_begin },
|
||||
fmt(
|
||||
[[
|
||||
\begin{{table}}
|
||||
\centering
|
||||
\begin{{tabular}}{{{}}}
|
||||
\hline
|
||||
{} & & & \\ \hline
|
||||
\end{{tabular}}
|
||||
\caption{{{}}}
|
||||
\label{{table:{}}}
|
||||
\end{{table}}
|
||||
]],
|
||||
{ i(1), i(4), i(2), i(3) }
|
||||
)
|
||||
),
|
||||
|
||||
-- ============== Basics ==============
|
||||
s("env", fmt("\\begin{{{}}}\n\t{}\n\\end{{{}}}", { i(1), i(2), rep(1) }, { name = "Environment" })),
|
||||
|
||||
-- ============== Direct env ==============
|
||||
s(
|
||||
{ trig = "abs", name = "Abstract", condition = line_begin },
|
||||
fmt("\\begin{{abstract}}\n\t{}\n\\end{{abstract}}", { i(1) })
|
||||
),
|
||||
|
||||
s(
|
||||
{ trig = "itm", name = "Environnement itemize", condition = line_begin },
|
||||
fmt("\\begin{{{}}}\n\t\\item {}\n\\end{{{}}}", { i(1, "itemize"), i(2), rep(1) })
|
||||
),
|
||||
|
||||
s({ trig = "it", name = "Add item", condition = line_begin }, fmt("\t\\item {}", { i(1) })),
|
||||
|
||||
-- ============== Section ==============
|
||||
s("sec", fmt("\\{}{{{}}}\\label{{sec:{}}}", { i(1), i(2), i(3) }, { name = "sections" })),
|
||||
|
||||
-- ============== Disp ==============
|
||||
s("bold", fmt("\\textbf{{{}}}", { i(1) }, { name = "bold" })),
|
||||
s("ital", fmt("\\textit{{{}}}", { i(1) }, { name = "italique" })),
|
||||
s("smcap", fmt("\\textsc{{{}}}", { i(1) }, { name = "small caps" })),
|
||||
s("_", fmt("_{{{}}}", { i(1) }, { name = "undertext" })),
|
||||
s("^", fmt("^{{{}}}", { i(1) }, { name = "uptext" })),
|
||||
|
||||
-- ============== Maths ==============
|
||||
s("frac", fmt("\\frac{{{}}}{{{}}}", { i(1), i(2) }, { name = "fraction" })),
|
||||
s("cases", fmt("\\begin{{cases}}\n\t{}\n\\end{{cases}}", { i(1) }, { name = "cases" })),
|
||||
|
||||
s(
|
||||
{ trig = "eq", name = "Equation", condition = line_begin },
|
||||
fmt("\\begin{{equation}}\n\t{}\n\t\\label{{eq:{}}}\n\\end{{equation}}", { i(1), i(2) })
|
||||
),
|
||||
|
||||
s(
|
||||
{ trig = "param", name = "Parameters", condition = line_begin },
|
||||
fmt("\\begin{{parameters}}\n\t{}\t& {}\t\n\\end{{parameters}}", { i(1), i(2) })
|
||||
),
|
||||
|
||||
s(
|
||||
{ trig = "align", name = "Align", condition = line_begin },
|
||||
fmt("\\begin{{align}}\n\t{}\n\t\\label{{eq:{}}}\n\\end{{align}}", { i(1), i(2) })
|
||||
),
|
||||
|
||||
s(
|
||||
{ trig = "mat", name = "Matrix", condition = line_begin },
|
||||
fmt("\\begin{{bmatrix}}\n\t{}\n\\end{{bmatrix}}", { i(1) })
|
||||
),
|
||||
|
||||
-- ============== Citation ==============
|
||||
s("ref", fmt("\\ref{{{}}}", { i(1) }, { name = "reference" })),
|
||||
s("cite", fmt("\\cite{{{}}}", { i(1) }, { name = "citation" })),
|
||||
|
||||
-- ============== Siunitx ==============
|
||||
s("num", fmt("\\num{{{}}}", { i(1) }, { name = "Number" })),
|
||||
s("un", fmt("\\unit{{{}}}", { i(1) }, { name = "Unit" })),
|
||||
s("quant", fmt("\\qty{{{}}}{{{}}}", { i(1), i(2) }, { name = "Quantity" })),
|
||||
s("ptm", t("\\ptm")),
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue