Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
TwIStOy committed Nov 24, 2023
1 parent ea7085c commit efb8f09
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 149 deletions.
62 changes: 0 additions & 62 deletions lua/ht/plugins/lsp/glance.lua

This file was deleted.

55 changes: 0 additions & 55 deletions lua/ht/plugins/lsp/lspkind.lua

This file was deleted.

28 changes: 0 additions & 28 deletions src/conf/actions/builtin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,6 @@ let lspActions = ActionGroupBuilder.start()
vim.lsp.buf.declaration();
},
})
.addOpts({
id: "builtin.lsp.goto-definition",
title: "Goto definition",
callback: () => {
luaRequire("glance").open("definitions");
},
})
.addOpts({
id: "builtin.lsp.goto-implementation",
title: "Goto implementation",
callback: () => {
luaRequire("glance").open("implementations");
},
})
.addOpts({
id: "builtin.lsp.goto-type-definition",
title: "Goto type definition",
callback: () => {
luaRequire("glance").open("type_definitions");
},
})
.addOpts({
id: "builtin.lsp.goto-reference",
title: "Goto reference",
callback: () => {
luaRequire("glance").open("references");
},
})
.addOpts({
id: "builtin.lsp.rename",
title: "Rename",
Expand Down
114 changes: 114 additions & 0 deletions src/conf/plugins/lsp/glance-nvim.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import {
ActionGroupBuilder,
Plugin,
PluginOptsBase,
andActions,
} from "@core/model";

const spec: PluginOptsBase = {
shortUrl: "dnlhc/glance.nvim",
lazy: {
lazy: true,
cmd: ["Glance"],
config: () => {
let glance = luaRequire("glance");
let actions = glance.actions;

glance.setup({
detached: (winid: number) => {
return vim.api.nvim_win_get_width(winid) < 100;
},
preview_win_opts: { cursorline: true, number: true, wrap: false },
border: { disable: true, top_char: "―", bottom_char: "―" },
theme: { enable: true },
list: { width: 0.2 },
mappings: {
list: {
["j"]: actions.next,
["k"]: actions.previous,
["<Down>"]: false,
["<Up>"]: false,
["<Tab>"]: actions.next_location,
["<S-Tab>"]: actions.previous_location,
["<C-u>"]: actions.preview_scroll_win(5),
["<C-d>"]: actions.preview_scroll_win(-5),
["v"]: false,
["s"]: false,
["t"]: false,
["<CR>"]: actions.jump,
["o"]: false,
["<leader>l"]: false,
["q"]: actions.close,
["Q"]: actions.close,
["<Esc>"]: actions.close,
},
preview: {
["Q"]: actions.close,
["<Tab>"]: false,
["<S-Tab>"]: false,
["<leader>l"]: false,
},
},
folds: { fold_closed: "󰅂", fold_open: "󰅀", folded: false },
indent_lines: { enable: false },
winbar: { enable: true },
hooks: {
before_open: (
results: any[],
open: any,
jump: any,
method: string
) => {
if (method === "references" || method === "implementations") {
open(results);
} else if (results.length === 1) {
jump(results[0]);
} else {
open(results);
}
},
},
});
},
},
};

function generateActions() {
return ActionGroupBuilder.start()
.category("LSP")
.from("glance.nvim")
.condition((buf) => {
return buf.lspServers.length > 0;
})
.addOpts({
id: "glance.goto-definition",
title: "Goto definition",
callback: () => {
luaRequire("glance").open("definitions");
},
})
.addOpts({
id: "glance.goto-implementation",
title: "Goto implementation",
callback: () => {
luaRequire("glance").open("implementations");
},
})
.addOpts({
id: "glance.goto-type-definition",
title: "Goto type definition",
callback: () => {
luaRequire("glance").open("type_definitions");
},
})
.addOpts({
id: "glance.goto-reference",
title: "Goto reference",
callback: () => {
luaRequire("glance").open("references");
},
})
.build();
}

export const plugin = new Plugin(andActions(spec, generateActions));
10 changes: 9 additions & 1 deletion src/conf/plugins/lsp/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { plugin as mason } from "./mason";
import { plugin as aerial } from "./aerial";
import { plugin as typescriptToolsNvim } from "./typescript-tools-nvim";
import { plugin as glanceNvim } from "./glance-nvim";
import { plugin as lspkindNvim } from "./lspkind-nvim";

export const plugins = [mason, aerial, typescriptToolsNvim] as const;
export const plugins = [
mason,
aerial,
typescriptToolsNvim,
glanceNvim,
lspkindNvim,
] as const;
54 changes: 54 additions & 0 deletions src/conf/plugins/lsp/lspkind-nvim.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Plugin, PluginOptsBase } from "@core/model";

const spec: PluginOptsBase = {
shortUrl: "onsails/lspkind.nvim",
lazy: {
lazy: true,
dependencies: ["nvim-tree/nvim-web-devicons"],
config: true,
opts: {
mode: "symbol_text",
symbol_map: {
Array: "",
Boolean: "",
Class: "",
Color: "",
Constant: "",
Constructor: "",
Enum: "",
EnumMember: "",
Event: "",
Field: "",
File: "",
Folder: "",
Function: "",
Interface: "",
Key: "",
Keyword: "",
Method: "",
Module: "",
Namespace: "",
Null: "",
Number: "",
Object: "",
Operator: "",
Package: "",
Property: "",
Reference: "",
Snippet: "",
String: "",
Struct: "",
Text: "",
TypeParameter: "",
Unit: "",
Value: "",
Variable: "",
Copilot: "",
Codeium: "",
Math: "󰀫",
},
},
},
};

export const plugin = new Plugin(spec);
6 changes: 3 additions & 3 deletions src/conf/ui/right-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,17 @@ const builtinLspGroup: RightClickMenuGroup = {
},
{
title: "Goto definition",
actionId: "builtin.lsp.goto-definition",
actionId: "glance.goto-definition",
keys: "D",
},
{
title: "Goto implementation",
actionId: "builtin.lsp.goto-implementation",
actionId: "glance.goto-implementation",
keys: "i",
},
{
title: "Inspect references",
actionId: "builtin.lsp.goto-reference",
actionId: "glance.goto-reference",
keys: "r",
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/types/vim/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ declare namespace vim {
export function nvim_win_set_buf(window: number, buffer: number): void;

export function nvim_win_get_buf(window: number): number;

export function nvim_win_get_width(window: number): number;

export function nvim_exec_autocmds(
event: string | string[],
Expand Down

0 comments on commit efb8f09

Please sign in to comment.