From 2a888388ea86bbbc8b6f177931a3ab24fa765495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Tue, 16 Jul 2024 06:57:23 +0200 Subject: [PATCH 1/3] use arrow keys for navigation --- config/programs/vim/config/lua/mappings.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/programs/vim/config/lua/mappings.lua b/config/programs/vim/config/lua/mappings.lua index 9355570b..c06f78f6 100644 --- a/config/programs/vim/config/lua/mappings.lua +++ b/config/programs/vim/config/lua/mappings.lua @@ -161,10 +161,10 @@ keymap.set("n", "gB", 'call buf_utils#GoToBuffer(v:count, "backward")', }) -- Switch windows -keymap.set("n", "", "h") -keymap.set("n", "", "l") -keymap.set("n", "", "k") -keymap.set("n", "", "j") +keymap.set("n", "", "h") +keymap.set("n", "", "l") +keymap.set("n", "", "k") +keymap.set("n", "", "j") -- Text objects for URL keymap.set({ "x", "o" }, "iu", "call text_obj#URL()", { desc = "URL text object" }) From 3745d69205002a5c9dbca606b8578e358f785241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Tue, 16 Jul 2024 07:19:47 +0200 Subject: [PATCH 2/3] remove snippets --- .../programs/vim/config/ftdetect/snippets.vim | 4 - .../config/lua/config/indent-blankline.lua | 2 +- .../vim/config/lua/config/nvim-cmp.lua | 9 - .../vim/config/my_snippets/all.snippets | 7 - .../vim/config/my_snippets/cpp.snippets | 182 ------------------ .../vim/config/my_snippets/markdown.snippets | 168 ---------------- .../vim/config/my_snippets/python.snippets | 30 --- .../vim/config/my_snippets/snippets.snippets | 6 - .../vim/config/my_snippets/tex.snippets | 9 - .../vim/config/my_snippets/vim.snippets | 14 -- .../programs/vim/config/viml_conf/plugins.vim | 17 +- config/programs/vim/plugins/lazy-nvim.nix | 8 - 12 files changed, 2 insertions(+), 454 deletions(-) delete mode 100644 config/programs/vim/config/ftdetect/snippets.vim delete mode 100644 config/programs/vim/config/my_snippets/all.snippets delete mode 100644 config/programs/vim/config/my_snippets/cpp.snippets delete mode 100644 config/programs/vim/config/my_snippets/markdown.snippets delete mode 100644 config/programs/vim/config/my_snippets/python.snippets delete mode 100644 config/programs/vim/config/my_snippets/snippets.snippets delete mode 100644 config/programs/vim/config/my_snippets/tex.snippets delete mode 100644 config/programs/vim/config/my_snippets/vim.snippets diff --git a/config/programs/vim/config/ftdetect/snippets.vim b/config/programs/vim/config/ftdetect/snippets.vim deleted file mode 100644 index 65e985ad..00000000 --- a/config/programs/vim/config/ftdetect/snippets.vim +++ /dev/null @@ -1,4 +0,0 @@ -augroup det_snippet - autocmd! - autocmd BufRead,BufNewFile *.snippets set filetype=snippets -augroup END \ No newline at end of file diff --git a/config/programs/vim/config/lua/config/indent-blankline.lua b/config/programs/vim/config/lua/config/indent-blankline.lua index 9b210d7d..4ec03277 100644 --- a/config/programs/vim/config/lua/config/indent-blankline.lua +++ b/config/programs/vim/config/lua/config/indent-blankline.lua @@ -1,6 +1,6 @@ local api = vim.api -local exclude_ft = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha", "dashboard" } +local exclude_ft = { "help", "git", "markdown", "text", "gitconfig", "alpha", "dashboard" } require("ibl").setup { indent = { diff --git a/config/programs/vim/config/lua/config/nvim-cmp.lua b/config/programs/vim/config/lua/config/nvim-cmp.lua index a402f1c7..99c04b0f 100644 --- a/config/programs/vim/config/lua/config/nvim-cmp.lua +++ b/config/programs/vim/config/lua/config/nvim-cmp.lua @@ -3,12 +3,6 @@ local cmp = require("cmp") local lspkind = require("lspkind") cmp.setup { - snippet = { - expand = function(args) - -- For `ultisnips` user. - vim.fn["UltiSnips#Anon"](args.body) - end, - }, mapping = cmp.mapping.preset.insert { [""] = function(fallback) if cmp.visible() then @@ -32,7 +26,6 @@ cmp.setup { }, sources = { { name = "nvim_lsp" }, -- For nvim-lsp - { name = "ultisnips" }, -- For ultisnips user. { name = "path" }, -- for path completion { name = "buffer", keyword_length = 2 }, -- for buffer word completion { name = "emoji", insert = true }, -- emoji completion @@ -49,7 +42,6 @@ cmp.setup { mode = "symbol_text", menu = { nvim_lsp = "[LSP]", - ultisnips = "[US]", nvim_lua = "[Lua]", path = "[Path]", buffer = "[Buffer]", @@ -63,7 +55,6 @@ cmp.setup { cmp.setup.filetype("tex", { sources = { { name = "omni" }, - { name = "ultisnips" }, -- For ultisnips user. { name = "buffer", keyword_length = 2 }, -- for buffer word completion { name = "path" }, -- for path completion }, diff --git a/config/programs/vim/config/my_snippets/all.snippets b/config/programs/vim/config/my_snippets/all.snippets deleted file mode 100644 index 443f6082..00000000 --- a/config/programs/vim/config/my_snippets/all.snippets +++ /dev/null @@ -1,7 +0,0 @@ -snippet "(? $1 -endsnippet \ No newline at end of file diff --git a/config/programs/vim/config/my_snippets/cpp.snippets b/config/programs/vim/config/my_snippets/cpp.snippets deleted file mode 100644 index 755ed1b6..00000000 --- a/config/programs/vim/config/my_snippets/cpp.snippets +++ /dev/null @@ -1,182 +0,0 @@ - -#include -#include -#include -#include -#include - -using std::cout; -using std::endl; -using std::vector; -using std::string; -using std::map; -using std::unordered_map; -using std::set; -using std::unordered_set; -using std::stack; -using std::queue; -using std::pair; -using std::make_pair; - - - -int main() -{ - - return 0; -} -endsnippet - -snippet icd "#include directive" b -#include <$1> -$0 -endsnippet - -snippet plist "print vector" w -template -void printList(const T& arr, const string& desc){ - std::cout << desc << ": ["; - - for (auto it = arr.begin(); it != arr.end(); it++){ - std::cout << *it << ((std::next(it) != arr.end()) ? ", " : ""); - } - std::cout << "]\n"; -} -endsnippet - -snippet pmat "print list of list" w -template -void printMat(const vector>& mat, const string& desc){ - cout << desc << ": " << endl; - - for (auto it1 = mat.begin(); it1 != mat.end(); it1++){ - auto cur_vec = *it1; - cout << "["; - for (auto it2 = cur_vec.begin(); it2 != cur_vec.end(); it2++){ - cout << *it2 << ((std::next(it2) != cur_vec.end()) ? ", " : "]\n"); - } - } -} -endsnippet - -snippet pqueue "print queue" -template -void printQueue(T q){ - while(!q.empty()){ - std::cout << q.top() << " "; - q.pop(); - } - std::cout << '\n'; -} -endsnippet - -snippet cout "print a variable" w -cout << "$1: " << $2 << endl; -endsnippet - -snippet random "Generate a random list" b -// Generate a random sequence of length len, in range(low, high) (inclusive). -// need to #include -vector genRandom(int low, int high, int len){ - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution distribution(low, high); - - vector arr(len, 0); - for (int i = 0; i != len; ++i){ - arr[i] = distribution(gen); - } - - return arr; -} -endsnippet - -snippet incset "Use set" b -#include - -using std::set; -endsnippet - -snippet incmap "Use map" b -#include - -using std::map; -endsnippet - -snippet incqueue "Use queue" b -#include - -using std::queue; -endsnippet - -snippet incstr "Use string" b -#include - -using std::string; -endsnippet - -snippet incvec "Use vector" b -#include - -using std::vector; -endsnippet - -snippet incstack "Use stack" b -#include - -using std::stack; -endsnippet - -snippet vec "std::vector" w -vector<$1> ${2:vec} -endsnippet - -snippet map "std::map" w -map<$1, $2> ${3:mymap} -endsnippet - -snippet umap "std::unordered_map" -unordered_map<$1, $2> ${3:mymap} -endsnippet - -snippet set "std::set" w -set<$1> ${2:myset} -endsnippet - -snippet uset "std::unordered_set" w -unordered_set<$1> ${2:myset} -endsnippet - -snippet queue "std::queue" w -queue<$1> ${2:q} -endsnippet - -snippet stack "std::stack" w -stack<$1> ${2:mystack} -endsnippet - -snippet sol "solution" w -auto solution = Solution(); -$0 -endsnippet - -snippet for "for loop" w -for ($1; $2; $3){ - $4 -} -endsnippet - -snippet if "if condition" w -if ($1){ - $2 -} -$0 -endsnippet - -snippet ifelse "if else condition" -if ($1){ - $2 -}else{ - -} -endsnippet \ No newline at end of file diff --git a/config/programs/vim/config/my_snippets/markdown.snippets b/config/programs/vim/config/my_snippets/markdown.snippets deleted file mode 100644 index 7af9efd2..00000000 --- a/config/programs/vim/config/my_snippets/markdown.snippets +++ /dev/null @@ -1,168 +0,0 @@ -global !p -def gen_header(snip): - placeholders_string = snip.buffer[snip.line].strip() - level = int(placeholders_string[0]) - - # erase current line - snip.buffer[snip.line] = "" - line_content = "#"*level + " ${1:Section Name}" - line_content += '\n$0' - - snip.expand_anon(line_content) -endglobal - -snippet "(k1|kbd)" "HTML kbd tag" rw -${1:KEY}$0 -endsnippet - -snippet k2 "Two key strokes shortcut" -${1:KEY} + ${2:KEY} -endsnippet - -snippet k3 "Three key strokes shortcut" -${1:KEY} + ${2:KEY} + ${3:KEY} -endsnippet - -snippet meta "Markdown front matter (YAML format)" b ---- -title: "$1" -date: `!p from datetime import datetime -if not snip.c: - snip.rv=datetime.now().astimezone().strftime("%Y-%m-%d %H:%M:%S%z")` -tags: [$2] -categories: [$3] ---- -$0 -endsnippet - -snippet more "HTML more tag" - -endsnippet - -snippet img "Aligned image using HTML tag" -

- -

-$0 -endsnippet - -snippet font "HTML font tag" -${2:TEXT} -endsnippet - -snippet link "Markdown links" -[$1]($2)$0 -endsnippet - -post_jump "gen_header(snip)" -snippet "h([1-6])" "Markdown header" br -`!p snip.rv = match.group(1)` -endsnippet - -snippet detail "Clickable details" b -
-${1:Click to show the code.} - -$2 -
-endsnippet - -snippet yh "直角引号" w -「$1」 -endsnippet - -snippet info "info box" - - -
- Info
- ${1:info text} -
-$0 -endsnippet - -snippet warn "warning box" - - -
- Warning
- ${1:warning text} -
-$0 -endsnippet - -snippet error "error box" - - -
- Error
- ${1:error text} -
-$0 -endsnippet - -snippet success "success box" - - -
- - ${1:success text} -
-$0 -endsnippet - -snippet td "too long do not read" bw -tl;dr: $1 -endsnippet \ No newline at end of file diff --git a/config/programs/vim/config/my_snippets/python.snippets b/config/programs/vim/config/my_snippets/python.snippets deleted file mode 100644 index ca80bc13..00000000 --- a/config/programs/vim/config/my_snippets/python.snippets +++ /dev/null @@ -1,30 +0,0 @@ -snippet head "Python source file header" b -""" -Description: $1 -Author: Jie-dong Hao (jdhao@hotmail.com) -Created: `!v strftime("%Y-%m-%d %H:%M:%S%z")` -""" -$0 -endsnippet - -snippet print "Print value of some variable" -print("$1".format($2)) -$0 -endsnippet - -snippet impa "import FOO as BAR" b -import ${1:FOO} as ${2:BAR} -endsnippet - -snippet main "Main function boilerplate" b -def main(): - $0 - - -if __name__ == "__main__": - main() -endsnippet - -snippet sol "solution" b -solution = Solution() -endsnippet \ No newline at end of file diff --git a/config/programs/vim/config/my_snippets/snippets.snippets b/config/programs/vim/config/my_snippets/snippets.snippets deleted file mode 100644 index bb1bad0d..00000000 --- a/config/programs/vim/config/my_snippets/snippets.snippets +++ /dev/null @@ -1,6 +0,0 @@ -# copied from https://github.com/honza/vim-snippets/blob/master/UltiSnips/snippets.snippets -snippet snip "Ultisnips snippet definition" b -`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b} -${0:${VISUAL}} -`!p snip.rv = "endsnippet"` -endsnippet \ No newline at end of file diff --git a/config/programs/vim/config/my_snippets/tex.snippets b/config/programs/vim/config/my_snippets/tex.snippets deleted file mode 100644 index bc0f9e35..00000000 --- a/config/programs/vim/config/my_snippets/tex.snippets +++ /dev/null @@ -1,9 +0,0 @@ -snippet use "usepackage" b -\usepackage{${1:package}} -endsnippet - -snippet eqa "equation environment" b -\begin{equation}\label{$1} - $2 -\end{equation} -endsnippet \ No newline at end of file diff --git a/config/programs/vim/config/my_snippets/vim.snippets b/config/programs/vim/config/my_snippets/vim.snippets deleted file mode 100644 index 758e7130..00000000 --- a/config/programs/vim/config/my_snippets/vim.snippets +++ /dev/null @@ -1,14 +0,0 @@ -snippet fun "vim function" -function! ${1:MyFunc}(${2}) abort - $3 -endfunction -$0 -endsnippet - -snippet aug "vim augroup" b -augroup ${1:GROUP_NAME} - autocmd! - autocmd ${2:EVENT} ${3:PATTERN} $4 -augroup END -$0 -endsnippet \ No newline at end of file diff --git a/config/programs/vim/config/viml_conf/plugins.vim b/config/programs/vim/config/viml_conf/plugins.vim index f5377fb2..487a7797 100644 --- a/config/programs/vim/config/viml_conf/plugins.vim +++ b/config/programs/vim/config/viml_conf/plugins.vim @@ -13,21 +13,6 @@ call utils#Cabbrev('ps', 'Lazy sync') " configurations for vim script plugin " """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -"""""""""""""""""""""""""UltiSnips settings""""""""""""""""""" -" Trigger configuration. Do not use if you use YouCompleteMe -let g:UltiSnipsExpandTrigger='' - -" Do not look for SnipMate snippets -let g:UltiSnipsEnableSnipMate = 0 - -" Shortcut to jump forward and backward in tabstop positions -let g:UltiSnipsJumpForwardTrigger='' -let g:UltiSnipsJumpBackwardTrigger='' - -" Configuration for custom snippets directory, see -" https://jdhao.github.io/2019/04/17/neovim_snippet_s1/ for details. -let g:UltiSnipsSnippetDirectories=['UltiSnips', 'my_snippets'] - """""""""""""""""""""""""" vlime settings """""""""""""""""""""""""""""""" command! -nargs=0 StartVlime call jobstart(printf("sbcl --load %s/vlime/lisp/start-vlime.lisp", g:package_home)) @@ -403,4 +388,4 @@ function! s:wilder_init() abort endfunction """"""""""""""""""""""""""""""vim-auto-save settings"""""""""""""""""""""""""""""" -let g:auto_save = 1 " enable AutoSave on Vim startup \ No newline at end of file +let g:auto_save = 1 " enable AutoSave on Vim startup diff --git a/config/programs/vim/plugins/lazy-nvim.nix b/config/programs/vim/plugins/lazy-nvim.nix index 6fcc0ea1..5ab420cf 100644 --- a/config/programs/vim/plugins/lazy-nvim.nix +++ b/config/programs/vim/plugins/lazy-nvim.nix @@ -21,7 +21,6 @@ cmp-buffer cmp-emoji cmp-nvim-lsp - cmp-nvim-ultisnips cmp-omni cmp-path committia-vim @@ -59,7 +58,6 @@ targets-vim telescope-nvim telescope-symbols-nvim - UltiSnips unicode-vim vim-auto-save vim-commentary @@ -76,7 +74,6 @@ vim-repeat vim-sandwich vim-scriptease - vim-snippets vim-swap vim-toml vimtex @@ -106,7 +103,6 @@ "hrsh7th/cmp-buffer", "hrsh7th/cmp-omni", "hrsh7th/cmp-emoji", - "quangnguyen30192/cmp-nvim-ultisnips", }, config = function() require("config.nvim-cmp") @@ -216,10 +212,6 @@ end, cmd = "Vista", }, - -- Snippet engine and snippet template - { "SirVer/ultisnips", dependencies = { - "honza/vim-snippets", - }, event = "InsertEnter" }, -- Automatic insertion and deletion of a pair of characters { "Raimondi/delimitMate", event = "InsertEnter" }, -- Comment plugin From 59d23bdca85a5a62bb9072742209de3cf8cefebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Tue, 16 Jul 2024 07:26:57 +0200 Subject: [PATCH 3/3] add cmp-ai --- .../programs/vim/config/lua/config/cmp-ai.lua | 19 +++++++++++++++++++ .../vim/config/lua/config/nvim-cmp.lua | 10 ++++++++++ config/programs/vim/plugins/lazy-nvim.nix | 11 +++++++++++ 3 files changed, 40 insertions(+) create mode 100644 config/programs/vim/config/lua/config/cmp-ai.lua diff --git a/config/programs/vim/config/lua/config/cmp-ai.lua b/config/programs/vim/config/lua/config/cmp-ai.lua new file mode 100644 index 00000000..5114f6ab --- /dev/null +++ b/config/programs/vim/config/lua/config/cmp-ai.lua @@ -0,0 +1,19 @@ +local cmp_ai = require('cmp_ai.config') + +cmp_ai:setup({ + max_lines = 100, + provider = 'Ollama', + provider_options = { + model = 'codellama:13b-code-q6_K', + }, + notify = true, + notify_callback = function(msg) + vim.notify(msg) + end, + run_on_every_keystroke = true, + ignored_file_types = { + -- default is not to ignore + -- uncomment to ignore in lua: + -- lua = true + }, +}) diff --git a/config/programs/vim/config/lua/config/nvim-cmp.lua b/config/programs/vim/config/lua/config/nvim-cmp.lua index 99c04b0f..ca018296 100644 --- a/config/programs/vim/config/lua/config/nvim-cmp.lua +++ b/config/programs/vim/config/lua/config/nvim-cmp.lua @@ -23,6 +23,16 @@ cmp.setup { [""] = cmp.mapping.close(), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping( + cmp.mapping.complete({ + config = { + sources = cmp.config.sources({ + { name = 'cmp_ai' }, + }), + }, + }), + { 'i' } + ), }, sources = { { name = "nvim_lsp" }, -- For nvim-lsp diff --git a/config/programs/vim/plugins/lazy-nvim.nix b/config/programs/vim/plugins/lazy-nvim.nix index 5ab420cf..70d88203 100644 --- a/config/programs/vim/plugins/lazy-nvim.nix +++ b/config/programs/vim/plugins/lazy-nvim.nix @@ -18,6 +18,7 @@ asyncrun-vim bufferline-nvim catppuccin-nvim + cmp-ai cmp-buffer cmp-emoji cmp-nvim-lsp @@ -103,11 +104,20 @@ "hrsh7th/cmp-buffer", "hrsh7th/cmp-omni", "hrsh7th/cmp-emoji", + "tzachar/cmp-ai" }, config = function() require("config.nvim-cmp") end, }, + { + "tzachar/cmp-ai", + event = "VeryLazy", + dependencies = {'nvim-lua/plenary.nvim'}, + config = function() + require("config.cmp-ai") + end, + }, { "neovim/nvim-lspconfig", event = { "BufRead", "BufNewFile" }, @@ -435,6 +445,7 @@ "stevearc", "tpope", "tyru", + "tzachar", "wellle", "Yggdroot", },