Skip to content

Commit d1a92e5

Browse files
committed
fix
1 parent 1093089 commit d1a92e5

File tree

7 files changed

+90
-87
lines changed

7 files changed

+90
-87
lines changed

lua/ht/plugins/coding/luasnip.lua

Lines changed: 0 additions & 84 deletions
This file was deleted.

lua/ht/version.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local M = {}
22

3-
M.last_updated_time = '2023.11.22'
3+
M.last_updated_time = '2023.11.23'
44

55
return M

src/conf/plugins/coding/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { plugin as cratesNvim } from "./crates-nvim";
55
import { plugin as nabla } from "./nabla";
66
import { plugin as neogen } from "./neogen";
77
import { plugin as rustToolsNvim } from "./rust-tools-nvim";
8+
import { plugin as luasnip } from "./luasnip";
89

910
export const plugins = [
1011
commentNvim,
@@ -14,4 +15,5 @@ export const plugins = [
1415
nabla,
1516
neogen,
1617
rustToolsNvim,
18+
luasnip,
1719
] as const;

src/conf/plugins/coding/luasnip.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { Plugin, PluginOptsBase } from "@core/model";
2+
3+
function addSnippets(ft: string, snippets: (LuaTable | (() => LuaTable))[]) {
4+
let ls = luaRequire("luasnip");
5+
let ret = snippets.map((s) => {
6+
if (typeof s === "function") {
7+
return s();
8+
}
9+
return s;
10+
});
11+
12+
ls.add_snippets(ft, ret);
13+
}
14+
15+
function addMappedSnippets(snippets: {
16+
[ft: string]: (LuaTable | (() => LuaTable))[];
17+
}) {
18+
for (let ft in snippets) {
19+
addSnippets(ft, snippets[ft]);
20+
}
21+
}
22+
23+
const spec: PluginOptsBase = {
24+
shortUrl: "L3MON4D3/LuaSnip",
25+
lazy: {
26+
build: "make install_jsregexp",
27+
event: ["InsertEnter"],
28+
config: () => {
29+
let ls = luaRequire("luasnip");
30+
let ft_functions = luaRequire("luasnip.extras.filetype_functions");
31+
32+
ls.config.setup({
33+
enable_autosnippets: true,
34+
history: false,
35+
updateevents: "TextChanged,TextChangedI",
36+
region_check_events: ["CursorMoved", "CursorMovedI", "CursorHold"],
37+
ft_func: ft_functions.from_pos_or_filetype,
38+
store_selection_keys: "<C-/>",
39+
});
40+
41+
addSnippets("all", luaRequire("ht.snippets.all")());
42+
addSnippets("cpp", luaRequire("ht.snippets.cpp")());
43+
addSnippets("rust", luaRequire("ht.snippets.rust")());
44+
addSnippets("lua", luaRequire("ht.snippets.lua")());
45+
addSnippets("dart", luaRequire("ht.snippets.dart")());
46+
addMappedSnippets(luaRequire("ht.snippets.markdown")());
47+
},
48+
keys: [
49+
{
50+
[1]: "<C-e>",
51+
[2]: () => {
52+
let ls = luaRequire("luasnip");
53+
if (ls.choice_active()) {
54+
ls.change_choice(1);
55+
}
56+
},
57+
mode: ["i", "s", "n", "v"],
58+
},
59+
{
60+
[1]: "<C-b>",
61+
[2]: () => {
62+
let ls = luaRequire("luasnip");
63+
if (ls.jumpable(-1)) {
64+
ls.jumpable(-1);
65+
}
66+
},
67+
mode: ["i", "s", "n", "v"],
68+
},
69+
{
70+
[1]: "<C-f>",
71+
[2]: () => {
72+
let ls = luaRequire("luasnip");
73+
if (ls.expand_or_jumpable()) {
74+
ls.expand_or_jump();
75+
}
76+
},
77+
mode: ["i", "s", "n", "v"],
78+
},
79+
],
80+
},
81+
allowInVscode: true,
82+
};
83+
84+
export const plugin = new Plugin(spec);

src/conf/plugins/ui/colorful-winsep-nvim.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const plugin = new Plugin({
1616
let filetype = vim.api.nvim_get_option_value("filetype", {
1717
buf: vim.api.nvim_win_get_buf(leftWinId),
1818
});
19-
if (filetype === "NvimTree") {
19+
if (filetype === "NvimTree" || filetype === "neo-tree") {
2020
luaRequire("colorful-winsep").NvimSeparatorDel();
2121
}
2222
}

src/conf/plugins/ui/neo-tree-nvim.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const spec: PluginOptsBase = {
2929
opts: {
3030
auto_clean_after_session_restore: true,
3131
close_if_last_window: true,
32+
enable_refresh_on_write: false,
3233
sources: ["filesystem", "buffers", "git_status"],
3334
source_selector: {
3435
winbar: true,

src/conf/plugins/ui/nvim-window-picker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const plugin = new Plugin({
88
opts: {
99
filter_rules: {
1010
bo: {
11-
filetype: ["NvimTree", "neo-tree", "notify"],
11+
filetype: ["NvimTree", "neo-tree", "notify", "NvimSeparator"],
1212
buftype: ["terminal"],
1313
},
1414
},

0 commit comments

Comments
 (0)