-
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
7 changed files
with
233 additions
and
201 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { LspServer } from "@core/model"; | ||
import { HttsContext } from "context"; | ||
|
||
function wrapOnAttach(defaultCallback: (client: any, bufnr: number) => void) { | ||
return (client: unknown, bufnr: number) => { | ||
defaultCallback(client, bufnr); | ||
|
||
vim.keymap.set( | ||
"n", | ||
"<leader>fa", | ||
() => { | ||
vim.api.nvim_command("ClangdSwitchSourceHeader"); | ||
}, | ||
{ | ||
desc: "clangd-switch-header", | ||
buffer: bufnr, | ||
} | ||
); | ||
}; | ||
} | ||
|
||
export const server = new LspServer({ | ||
name: "clangd", | ||
exe: { | ||
masonPkg: "clangd", | ||
}, | ||
setup(_server: LspServer, on_attach: () => void, capabilities: LuaTable) { | ||
luaRequire("lspconfig").clangd.setup({ | ||
cmd: [ | ||
`${HttsContext.getInstance().masonBinRoot}/clangd`, | ||
"--clang-tidy", | ||
"--background-index", | ||
"--background-index-priority=normal", | ||
"--ranking-model=decision_forest", | ||
"--completion-style=detailed", | ||
"--header-insertion=iwyu", | ||
"--limit-references=100", | ||
"--limit-results=100", | ||
"--include-cleaner-stdlib", | ||
"-j=20", | ||
], | ||
on_attach: wrapOnAttach(on_attach), | ||
capabilities: capabilities, | ||
filetypes: ["c", "cpp"], | ||
}); | ||
|
||
luaRequire("clangd_extensions").setup({ | ||
extensions: { | ||
autoSetHints: false, | ||
hover_with_actions: true, | ||
inlay_hints: { | ||
inline: false, | ||
only_current_line: false, | ||
only_current_line_autocmd: "CursorHold", | ||
show_parameter_hints: false, | ||
show_variable_name: true, | ||
other_hints_prefix: "", | ||
max_len_align: false, | ||
max_len_align_padding: 1, | ||
right_align: false, | ||
right_align_padding: 7, | ||
highlight: "Comment", | ||
}, | ||
ast: { | ||
role_icons: { | ||
type: "🄣", | ||
declaration: "🄓", | ||
expression: "🄔", | ||
statement: ";", | ||
specifier: "🄢", | ||
["template argument"]: "🆃", | ||
}, | ||
kind_icons: { | ||
Compound: "🄲", | ||
Recovery: "🅁", | ||
TranslationUnit: "🅄", | ||
PackExpansion: "🄿", | ||
TemplateTypeParm: "🅃", | ||
TemplateTemplateParm: "🅃", | ||
TemplateParamObject: "🅃", | ||
}, | ||
}, | ||
memory_usage: { border: "rounded" }, | ||
symbol_info: { border: "rounded" }, | ||
}, | ||
}); | ||
}, | ||
}); |
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,3 +1,4 @@ | ||
import TypescriptTool from "./typescript-tools"; | ||
import typescriptTool from "./typescript-tools"; | ||
import { server as clangdTool } from "./clangd"; | ||
|
||
export default [TypescriptTool]; | ||
export default [typescriptTool, clangdTool]; |
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,55 @@ | ||
import { | ||
ActionGroupBuilder, | ||
Plugin, | ||
PluginOptsBase, | ||
andActions, | ||
} from "@core/model"; | ||
|
||
const spec: PluginOptsBase = { | ||
shortUrl: "p00f/clangd_extensions.nvim", | ||
lazy: { | ||
lazy: true, | ||
}, | ||
}; | ||
|
||
function generateActions() { | ||
return ActionGroupBuilder.start() | ||
.category("Clangd") | ||
.from("clangd_extensions.nvim") | ||
.condition((buf) => { | ||
for (let server of buf.lspServers) { | ||
if (server.name === "clangd") { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}) | ||
.addOpts({ | ||
id: "clangd.switch-source-header", | ||
title: "Switch between source and header files", | ||
callback: "ClangdSwitchSourceHeader", | ||
}) | ||
.addOpts({ | ||
id: "clangd.view-ast", | ||
title: "View AST", | ||
callback: "ClangdAST", | ||
}) | ||
.addOpts({ | ||
id: "clangd.view-type-hierarchy", | ||
title: "View type hierarchy", | ||
callback: "ClangdTypeHierarchy", | ||
}) | ||
.addOpts({ | ||
id: "clangd.symbol-info", | ||
title: "Symbol info", | ||
callback: "ClangdSymbolInfo", | ||
}) | ||
.addOpts({ | ||
id: "clangd.memory-usage", | ||
title: "Memory usage", | ||
callback: "ClangdMemoryUsage", | ||
}) | ||
.build(); | ||
} | ||
|
||
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
Oops, something went wrong.