NVim: snippets
This commit is contained in:
parent
7a351e49fe
commit
ffbd6a40fe
5 changed files with 197 additions and 14 deletions
|
|
@ -1,20 +1,6 @@
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
local luasnip = require("luasnip")
|
local luasnip = require("luasnip")
|
||||||
|
|
||||||
local keymap = vim.keymap
|
|
||||||
keymap.set({"i"}, "<C-K>", function() luasnip.expand() end, {silent = true})
|
|
||||||
keymap.set({"i", "s"}, "<C-l>", function() luasnip.jump( 1) end, {silent = true})
|
|
||||||
keymap.set({"i", "s"}, "<C-h>", function() luasnip.jump(-1) end, {silent = true})
|
|
||||||
|
|
||||||
vim.keymap.set({"i", "s"}, "<C-E>", function()
|
|
||||||
if luasnip.choice_active() then
|
|
||||||
luasnip.change_choice(1)
|
|
||||||
end
|
|
||||||
end, {silent = true})
|
|
||||||
|
|
||||||
-- loads vscode style snippets from installed plugins (eg. friendly-snippets)
|
|
||||||
require("luasnip.loaders.from_vscode").lazy_load()
|
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
completion = {
|
completion = {
|
||||||
completeopt = "menu,menuone,preview,noselect"
|
completeopt = "menu,menuone,preview,noselect"
|
||||||
|
|
@ -25,6 +11,8 @@ cmp.setup({
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<Up>"] = cmp.mapping.select_prev_item(), -- previous suggestion
|
||||||
|
["<Down>"] = cmp.mapping.select_next_item(), -- next suggestion
|
||||||
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
|
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
|
||||||
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
|
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
|
||||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
|
|
||||||
128
modules/hm/nvim/snippets/markdown.json
Normal file
128
modules/hm/nvim/snippets/markdown.json
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
{
|
||||||
|
"Thesis structure": {
|
||||||
|
"prefix": "thesis structure",
|
||||||
|
"body": [
|
||||||
|
"## Introduction",
|
||||||
|
"",
|
||||||
|
"- Def. problema",
|
||||||
|
"- Motivations",
|
||||||
|
"- Thesis/Research questions",
|
||||||
|
"",
|
||||||
|
"## Background",
|
||||||
|
"",
|
||||||
|
"- Basic information required to understand the research",
|
||||||
|
"- Related work (similar works, pubblications)",
|
||||||
|
"",
|
||||||
|
"## Methodology",
|
||||||
|
"",
|
||||||
|
"- How do i test the thesis",
|
||||||
|
"",
|
||||||
|
"## Experiments",
|
||||||
|
"",
|
||||||
|
"- I do the experiments and verify the thesis (I try to disprove it)",
|
||||||
|
"",
|
||||||
|
"## Discussion",
|
||||||
|
"",
|
||||||
|
"- Comments on the obtained results",
|
||||||
|
"",
|
||||||
|
"## Conclusioni",
|
||||||
|
"",
|
||||||
|
"- Summary of the contents",
|
||||||
|
"- Remarks on future works",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"description": "Thesis structure"
|
||||||
|
},
|
||||||
|
"Person": {
|
||||||
|
"prefix": "person",
|
||||||
|
"body": [
|
||||||
|
"---",
|
||||||
|
"aliases: []",
|
||||||
|
"type: person",
|
||||||
|
"relationship: []",
|
||||||
|
"email: ${2:email}",
|
||||||
|
"---",
|
||||||
|
"",
|
||||||
|
"# ${1:example}",
|
||||||
|
"",
|
||||||
|
"- **Email**: ${2:email}"
|
||||||
|
],
|
||||||
|
"description": "Person"
|
||||||
|
},
|
||||||
|
"Thesis student": {
|
||||||
|
"prefix": "thesis student",
|
||||||
|
"body": [
|
||||||
|
"---",
|
||||||
|
"type: person",
|
||||||
|
"email: ${2:email}",
|
||||||
|
"relationships: [thesis_student]",
|
||||||
|
"supervisor: ${4:supervisor}",
|
||||||
|
"cosupervisors: [Filippo Berto]",
|
||||||
|
"thesis: ${3:thesis title}",
|
||||||
|
"---",
|
||||||
|
"",
|
||||||
|
"# ${1:name}",
|
||||||
|
"",
|
||||||
|
"- **Email**: ${2:example}",
|
||||||
|
"- **Thesis**: [[${3:thesis title}]]",
|
||||||
|
"- **Supervisor**: [[${4:supervisor}]]",
|
||||||
|
"- **Co-supervisor**: [Filippo Berto]"
|
||||||
|
],
|
||||||
|
"description": "Thesis student"
|
||||||
|
},
|
||||||
|
"Thesis": {
|
||||||
|
"prefix": "thesis",
|
||||||
|
"body": [
|
||||||
|
"---",
|
||||||
|
"type: thesis",
|
||||||
|
"title: ${1:title}",
|
||||||
|
"grade: ${2:grade}",
|
||||||
|
"supervisor: ${3:supervisor}",
|
||||||
|
"cosupervisors: [Filippo Berto]",
|
||||||
|
"tags: [${4:example}]",
|
||||||
|
"---",
|
||||||
|
"",
|
||||||
|
"# ${1:title}",
|
||||||
|
"",
|
||||||
|
"- **Supervisor**: [[${2:supervisor}]]",
|
||||||
|
"- **Co-supervisor**: [[Filippo Berto]]",
|
||||||
|
"- **Grade**: ${3:grade}",
|
||||||
|
"",
|
||||||
|
"**Main points**:"
|
||||||
|
],
|
||||||
|
"description": "Thesis"
|
||||||
|
},
|
||||||
|
"Meeting": {
|
||||||
|
"prefix": "meeting",
|
||||||
|
"body": [
|
||||||
|
"---",
|
||||||
|
"type: meeting",
|
||||||
|
"people: [Filippo Berto, ${2:people}]",
|
||||||
|
"date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE",
|
||||||
|
"topic: ${1:title}",
|
||||||
|
"---",
|
||||||
|
"",
|
||||||
|
"# ${1:title}",
|
||||||
|
"",
|
||||||
|
"## Step 1",
|
||||||
|
"",
|
||||||
|
"## Step 2"
|
||||||
|
],
|
||||||
|
"description": "Meeting"
|
||||||
|
},
|
||||||
|
"Note of the day": {
|
||||||
|
"prefix": "note of the day",
|
||||||
|
"body": [
|
||||||
|
"---",
|
||||||
|
"date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE",
|
||||||
|
"---",
|
||||||
|
"",
|
||||||
|
"# ${1:title}",
|
||||||
|
"",
|
||||||
|
"## Step 1",
|
||||||
|
"",
|
||||||
|
"## Step 2"
|
||||||
|
],
|
||||||
|
"description": "Note of the day"
|
||||||
|
}
|
||||||
|
}
|
||||||
14
modules/hm/nvim/snippets/package.json
Normal file
14
modules/hm/nvim/snippets/package.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "personal-snippets",
|
||||||
|
"engines": {
|
||||||
|
"vscode": "^1.11.0"
|
||||||
|
},
|
||||||
|
"contributes": {
|
||||||
|
"snippets": [
|
||||||
|
{
|
||||||
|
"language": ["markdown", "rmd"],
|
||||||
|
"path": "./markdown.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
1
modules/hm/readme.md
Normal file
1
modules/hm/readme.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -60,6 +60,31 @@ let vp = pkgs.vimPlugins; in {
|
||||||
vp.cmp-buffer # source for text in buffer
|
vp.cmp-buffer # source for text in buffer
|
||||||
vp.cmp-path # source for file system path
|
vp.cmp-path # source for file system path
|
||||||
vp.luasnip
|
vp.luasnip
|
||||||
|
|
||||||
|
{
|
||||||
|
plugin = vp.luasnip;
|
||||||
|
type = "lua";
|
||||||
|
config = ''
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
local keymap = vim.keymap
|
||||||
|
keymap.set({"i"}, "<C-K>", function() luasnip.expand() end, {silent = true})
|
||||||
|
keymap.set({"i", "s"}, "<C-l>", function() luasnip.jump( 1) end, {silent = true})
|
||||||
|
keymap.set({"i", "s"}, "<C-h>", function() luasnip.jump(-1) end, {silent = true})
|
||||||
|
|
||||||
|
vim.keymap.set({"i", "s"}, "<C-E>", function()
|
||||||
|
if luasnip.choice_active() then
|
||||||
|
luasnip.change_choice(1)
|
||||||
|
end
|
||||||
|
end, {silent = true})
|
||||||
|
|
||||||
|
-- loads vscode style snippets from installed plugins (eg. friendly-snippets)
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load({ paths = "${./nvim/snippets}" })
|
||||||
|
|
||||||
|
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
vp.cmp_luasnip
|
vp.cmp_luasnip
|
||||||
vp.friendly-snippets
|
vp.friendly-snippets
|
||||||
{
|
{
|
||||||
|
|
@ -187,6 +212,26 @@ let vp = pkgs.vimPlugins; in {
|
||||||
include_surrounding_whitespace = true,
|
include_surrounding_whitespace = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||||
|
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||||
|
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||||
|
-- Instead of true it can also be a list of languages
|
||||||
|
additional_vim_regex_highlighting = false,
|
||||||
|
},
|
||||||
|
incremental_selection = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
init_selection = "gnn", -- set to `false` to disable one of the mappings
|
||||||
|
node_incremental = "grn",
|
||||||
|
scope_incremental = "grc",
|
||||||
|
node_decremental = "grm",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
indent = {
|
||||||
|
enable = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
@ -249,6 +294,7 @@ let vp = pkgs.vimPlugins; in {
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vp.nvim-treesitter-context
|
||||||
];
|
];
|
||||||
# settings = { ignorecase = true; };
|
# settings = { ignorecase = true; };
|
||||||
# coc.enable = true;
|
# coc.enable = true;
|
||||||
|
|
@ -310,6 +356,12 @@ let vp = pkgs.vimPlugins; in {
|
||||||
opt.whichwrap:append "<>[]hl"
|
opt.whichwrap:append "<>[]hl"
|
||||||
|
|
||||||
g.mapleader = " "
|
g.mapleader = " "
|
||||||
|
|
||||||
|
-- treesitter folding
|
||||||
|
vim.opt.foldmethod = "expr"
|
||||||
|
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||||
|
-- vim.cmd([[ set nofoldenable]])
|
||||||
|
vim.opt.foldenable = false
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue