-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
166 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
return { | ||
{ | ||
"TwIStOy/neodim", | ||
"zbirenbaum/neodim", | ||
lazy = true, | ||
event = "LspAttach", | ||
config = function() | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { | ||
ActionGroupBuilder, | ||
Plugin, | ||
PluginOptsBase, | ||
andActions, | ||
removeReadonly, | ||
} from "@core/model"; | ||
|
||
const spec: PluginOptsBase = { | ||
shortUrl: "folke/trouble.nvim", | ||
lazy: { | ||
dependencies: ["folke/lsp-colors.nvim"], | ||
lazy: true, | ||
cmd: ["Trouble", "TroubleClose", "TroubleToggle", "TroubleRefresh"], | ||
}, | ||
}; | ||
|
||
function generateActions() { | ||
const lspActions = ActionGroupBuilder.start() | ||
.category("Trouble") | ||
.from("trouble.nvim") | ||
.condition((buf) => { | ||
return buf.lspServers.length > 0; | ||
}) | ||
.addOpts({ | ||
id: "trouble.open-workspace-diagnostic", | ||
title: "Open workspace diagnostic (Trouble)", | ||
callback: "Trouble workspace_diagnostic", | ||
keys: { | ||
[1]: "<leader>xw", | ||
desc: "lsp-workspace-diagnostic", | ||
}, | ||
}) | ||
.addOpts({ | ||
id: "trouble.open-document-diagnostic", | ||
title: "Open document diagnostic (Trouble)", | ||
callback: "Trouble document_diagnostic", | ||
keys: { | ||
[1]: "<leader>xd", | ||
desc: "lsp-document-diagnostic", | ||
}, | ||
}) | ||
.build(); | ||
const commonActions = ActionGroupBuilder.start() | ||
.category("Trouble") | ||
.from("trouble.nvim") | ||
.addOpts({ | ||
id: "trouble.toggle-indow", | ||
title: "Toggle trouble window", | ||
callback: "TroubleToggle", | ||
keys: { | ||
[1]: "<leader>xx", | ||
desc: "trouble-toggle", | ||
}, | ||
}) | ||
.build(); | ||
const actionsInTroubleWindow = ActionGroupBuilder.start() | ||
.category("Trouble") | ||
.from("trouble.nvim") | ||
.condition(() => { | ||
return luaRequire("trouble").is_open(); | ||
}) | ||
.addOpts({ | ||
id: "trouble.previous-trouble", | ||
title: "Previous trouble item", | ||
callback: () => { | ||
luaRequire("trouble").previous({ skip_groups: true, jump: true }); | ||
}, | ||
keys: { | ||
[1]: "[q]", | ||
desc: "previous-trouble", | ||
}, | ||
}) | ||
.addOpts({ | ||
id: "trouble.next-trouble", | ||
title: "Next trouble item", | ||
callback: () => { | ||
luaRequire("trouble").next({ skip_groups: true, jump: true }); | ||
}, | ||
keys: { | ||
[1]: "]q]", | ||
desc: "next-trouble", | ||
}, | ||
}) | ||
.build(); | ||
return removeReadonly([ | ||
...lspActions, | ||
...commonActions, | ||
...actionsInTroubleWindow, | ||
] as const); | ||
} | ||
|
||
export const plugin = new Plugin(andActions(spec, generateActions)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { VimBuffer, system } from "@core/vim"; | ||
|
||
export async function inGitRepo(buffer?: VimBuffer): Promise<boolean> { | ||
let cwd: string | undefined; | ||
if (buffer && buffer.fullFileName) { | ||
cwd = vim.fn.fnamemodify(buffer.fullFileName, ":h"); | ||
} | ||
let ret = await system(["git", "rev-parse", "--is-inside-work-tree"], { | ||
cwd, | ||
}); | ||
return ret.code === 0; | ||
} | ||
|
||
export async function getCurrentRepoPath( | ||
buffer?: VimBuffer | ||
): Promise<string | null> { | ||
let cwd: string | undefined; | ||
if (buffer && buffer.fullFileName) { | ||
cwd = vim.fn.fnamemodify(buffer.fullFileName, ":h"); | ||
} | ||
let ret = await system(["git", "rev-parse", "--show-toplevel"], { | ||
cwd, | ||
}); | ||
if (ret.code !== 0) { | ||
return null; | ||
} | ||
return ret.stdout!.trim(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters