initial commit, support for C/C++ and Latex
This commit is contained in:
commit
2e50848938
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
lazy-lock.json
|
91
config.lua
Normal file
91
config.lua
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
-- Read the docs: https://www.lunarvim.org/docs/configuration
|
||||||
|
-- Example configs: https://github.com/LunarVim/starter.lvim
|
||||||
|
-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6
|
||||||
|
-- Forum: https://www.reddit.com/r/lunarvim/
|
||||||
|
-- Discord: https://discord.com/invite/Xb9B4Ny
|
||||||
|
|
||||||
|
require("user.c")
|
||||||
|
require("user.latex")
|
||||||
|
|
||||||
|
lvim.colorscheme = "catppuccin-frappe"
|
||||||
|
vim.opt.rnu = true -- relative numbers
|
||||||
|
vim.opt.cb = "unnamedplus"
|
||||||
|
vim.opt.nf = "alpha,octal,hex,bin,unsigned"
|
||||||
|
vim.opt.si = true
|
||||||
|
vim.opt.backup = false
|
||||||
|
lvim.builtin.nvimtree.active = false -- NOTE: using neo-tree
|
||||||
|
lvim.builtin.indentlines.active = true
|
||||||
|
|
||||||
|
vim.opt.ts = 2
|
||||||
|
vim.opt.sw = 2
|
||||||
|
vim.opt.et = false
|
||||||
|
|
||||||
|
lvim.keys.normal_mode["<A-e>"] = ":NeoTreeFocusToggle<CR>"
|
||||||
|
lvim.keys.normal_mode["<C-h>"] = ":BufferLineCyclePrev<CR>"
|
||||||
|
lvim.keys.normal_mode["<C-l>"] = ":BufferLineCycleNext<CR>"
|
||||||
|
|
||||||
|
lvim.format_on_save = false
|
||||||
|
vim.diagnostic.config( { virtual_text = true } )
|
||||||
|
|
||||||
|
lvim.builtin.treesitter.highlight.enable = true
|
||||||
|
|
||||||
|
-- auto install treesitter parsers
|
||||||
|
lvim.builtin.treesitter.ensure_installed = { "cpp", "c", "latex" }
|
||||||
|
|
||||||
|
-- Additional Plugins
|
||||||
|
table.insert(lvim.plugins, {
|
||||||
|
"p00f/clangd_extensions.nvim",
|
||||||
|
"catppuccin/nvim",
|
||||||
|
"nyoom-engineering/oxocarbon.nvim",
|
||||||
|
"rose-pine/neovim",
|
||||||
|
{
|
||||||
|
"nvim-neo-tree/neo-tree.nvim",
|
||||||
|
branch = "v2.x",
|
||||||
|
dependencies = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
"nvim-tree/nvim-web-devicons",
|
||||||
|
"MunifTanjim/nui.nvim",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require("neo-tree").setup({
|
||||||
|
close_if_last_window = true,
|
||||||
|
window = {
|
||||||
|
width = 30,
|
||||||
|
},
|
||||||
|
buffers = {
|
||||||
|
follow_current_file = true,
|
||||||
|
},
|
||||||
|
filesystem = {
|
||||||
|
follow_current_file = true,
|
||||||
|
filtered_items = {
|
||||||
|
hide_dotfiles = false,
|
||||||
|
hide_gitignored = false,
|
||||||
|
hide_by_name = {
|
||||||
|
"node_modules"
|
||||||
|
},
|
||||||
|
never_show = {
|
||||||
|
".DS_Store",
|
||||||
|
"thumbs.db"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
},
|
||||||
|
"lervag/vimtex",
|
||||||
|
"kdheepak/cmp-latex-symbols",
|
||||||
|
"KeitaNakamura/tex-conceal.vim",
|
||||||
|
"SirVer/ultisnips",
|
||||||
|
{
|
||||||
|
"ggandor/leap.nvim",
|
||||||
|
name = "leap",
|
||||||
|
config = function()
|
||||||
|
require("leap").add_default_mappings()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mrjones2014/nvim-ts-rainbow",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "clangd" })
|
102
lua/user/c.lua
Normal file
102
lua/user/c.lua
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "clangd" })
|
||||||
|
|
||||||
|
-- some settings can only passed as commandline flags, see `clangd --help`
|
||||||
|
local clangd_flags = {
|
||||||
|
"--background-index",
|
||||||
|
"--fallback-style=Google",
|
||||||
|
"--all-scopes-completion",
|
||||||
|
"--clang-tidy",
|
||||||
|
"--log=error",
|
||||||
|
"--suggest-missing-includes",
|
||||||
|
"--cross-file-rename",
|
||||||
|
"--completion-style=detailed",
|
||||||
|
"--pch-storage=memory", -- could also be disk
|
||||||
|
"--folding-ranges",
|
||||||
|
"--enable-config", -- clangd 11+ supports reading from .clangd configuration file
|
||||||
|
"--offset-encoding=utf-16", --temporary fix for null-ls
|
||||||
|
-- "--limit-references=1000",
|
||||||
|
-- "--limit-resutls=1000",
|
||||||
|
-- "--malloc-trim",
|
||||||
|
-- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type",
|
||||||
|
-- "--header-insertion=never",
|
||||||
|
-- "--query-driver=<list-of-white-listed-complers>"
|
||||||
|
}
|
||||||
|
|
||||||
|
local provider = "clangd"
|
||||||
|
|
||||||
|
local custom_on_attach = function(client, bufnr)
|
||||||
|
require("lvim.lsp").common_on_attach(client, bufnr)
|
||||||
|
|
||||||
|
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||||
|
vim.keymap.set("n", "<leader>lh", "<cmd>ClangdSwitchSourceHeader<cr>", opts)
|
||||||
|
vim.keymap.set("x", "<leader>lA", "<cmd>ClangdAST<cr>", opts)
|
||||||
|
vim.keymap.set("n", "<leader>lH", "<cmd>ClangdTypeHierarchy<cr>", opts)
|
||||||
|
vim.keymap.set("n", "<leader>lt", "<cmd>ClangdSymbolInfo<cr>", opts)
|
||||||
|
vim.keymap.set("n", "<leader>lm", "<cmd>ClangdMemoryUsage<cr>", opts)
|
||||||
|
|
||||||
|
require("clangd_extensions.inlay_hints").setup_autocmd()
|
||||||
|
require("clangd_extensions.inlay_hints").set_inlay_hints()
|
||||||
|
end
|
||||||
|
|
||||||
|
local status_ok, project_config = pcall(require, "rhel.clangd_wrl")
|
||||||
|
if status_ok then
|
||||||
|
clangd_flags = vim.tbl_deep_extend("keep", project_config, clangd_flags)
|
||||||
|
end
|
||||||
|
|
||||||
|
local custom_on_init = function(client, bufnr)
|
||||||
|
require("lvim.lsp").common_on_init(client, bufnr)
|
||||||
|
require("clangd_extensions.config").setup {}
|
||||||
|
require("clangd_extensions.ast").init()
|
||||||
|
vim.cmd [[
|
||||||
|
command ClangdToggleInlayHints lua require('clangd_extensions.inlay_hints').toggle_inlay_hints()
|
||||||
|
command -range ClangdAST lua require('clangd_extensions.ast').display_ast(<line1>, <line2>)
|
||||||
|
command ClangdTypeHierarchy lua require('clangd_extensions.type_hierarchy').show_hierarchy()
|
||||||
|
command ClangdSymbolInfo lua require('clangd_extensions.symbol_info').show_symbol_info()
|
||||||
|
command -nargs=? -complete=customlist,s:memuse_compl ClangdMemoryUsage lua require('clangd_extensions.memory_usage').show_memory_usage('<args>' == 'expand_preamble')
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
|
||||||
|
local opts = {
|
||||||
|
cmd = { provider, unpack(clangd_flags) },
|
||||||
|
on_attach = custom_on_attach,
|
||||||
|
on_init = custom_on_init,
|
||||||
|
}
|
||||||
|
|
||||||
|
require("lvim.lsp.manager").setup("clangd", opts)
|
||||||
|
|
||||||
|
-- install codelldb with :MasonInstall codelldb
|
||||||
|
-- configure nvim-dap (codelldb)
|
||||||
|
lvim.builtin.dap.on_config_done = function(dap)
|
||||||
|
dap.adapters.codelldb = {
|
||||||
|
type = "server",
|
||||||
|
port = "${port}",
|
||||||
|
executable = {
|
||||||
|
-- provide the absolute path for `codelldb` command if not using the one installed using `mason.nvim`
|
||||||
|
command = "codelldb",
|
||||||
|
args = { "--port", "${port}" },
|
||||||
|
|
||||||
|
-- On windows you may have to uncomment this:
|
||||||
|
-- detached = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.cpp = {
|
||||||
|
{
|
||||||
|
name = "Launch file",
|
||||||
|
type = "codelldb",
|
||||||
|
request = "launch",
|
||||||
|
program = function()
|
||||||
|
local path
|
||||||
|
vim.ui.input({ prompt = "Path to executable: ", default = vim.loop.cwd() .. "/build/" }, function(input)
|
||||||
|
path = input
|
||||||
|
end)
|
||||||
|
vim.cmd [[redraw]]
|
||||||
|
return path
|
||||||
|
end,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
stopOnEntry = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.c = dap.configurations.cpp
|
||||||
|
end
|
87
lua/user/latex.lua
Normal file
87
lua/user/latex.lua
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
-- Setup Lsp.
|
||||||
|
local capabilities = require("lvim.lsp").common_capabilities()
|
||||||
|
require("lvim.lsp.manager").setup("texlab", {
|
||||||
|
on_attach = require("lvim.lsp").common_on_attach,
|
||||||
|
on_init = require("lvim.lsp").common_on_init,
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Setup formatters.
|
||||||
|
local formatters = require("lvim.lsp.null-ls.formatters")
|
||||||
|
formatters.setup({
|
||||||
|
{ command = "latexindent", filetypes = { "tex" } },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Set a linter.
|
||||||
|
local linters = require("lvim.lsp.null-ls.linters")
|
||||||
|
linters.setup({
|
||||||
|
{ command = "chktex", filetypes = { "tex" } },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- UltiSnip configuration.
|
||||||
|
vim.cmd([[
|
||||||
|
let g:UltiSnipsExpandTrigger="<CR>"
|
||||||
|
let g:UltiSnipsJumpForwardTrigger="<Plug>(ultisnips_jump_forward)"
|
||||||
|
let g:UltiSnipsJumpBackwardTrigger="<Plug>(ultisnips_jump_backward)"
|
||||||
|
let g:UltiSnipsListSnippets="<c-x><c-s>"
|
||||||
|
let g:UltiSnipsRemoveSelectModeMappings=0
|
||||||
|
let g:UltiSnipsEditSplit="tabdo"
|
||||||
|
let g:UltiSnipsSnippetDirectories=[$HOME."/.config/nvim/UltiSnips"]
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- Vimtex configuration.
|
||||||
|
vim.g.vimtex_view_method = "zathura"
|
||||||
|
vim.g.vimtex_quickfix_enabled = 0
|
||||||
|
|
||||||
|
-- Setup cmp.
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
group = vim.api.nvim_create_augroup("LaTeXGroup", { clear = true }),
|
||||||
|
pattern = "tex",
|
||||||
|
callback = function()
|
||||||
|
require("user.cmp")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Mappings
|
||||||
|
lvim.builtin.which_key.mappings["C"] = {
|
||||||
|
name = "LaTeX",
|
||||||
|
m = { "<cmd>VimtexContextMenu<CR>", "Open Context Menu" },
|
||||||
|
u = { "<cmd>VimtexCountLetters<CR>", "Count Letters" },
|
||||||
|
w = { "<cmd>VimtexCountWords<CR>", "Count Words" },
|
||||||
|
d = { "<cmd>VimtexDocPackage<CR>", "Open Doc for package" },
|
||||||
|
e = { "<cmd>VimtexErrors<CR>", "Look at the errors" },
|
||||||
|
s = { "<cmd>VimtexStatus<CR>", "Look at the status" },
|
||||||
|
a = { "<cmd>VimtexToggleMain<CR>", "Toggle Main" },
|
||||||
|
v = { "<cmd>VimtexView<CR>", "View pdf" },
|
||||||
|
i = { "<cmd>VimtexInfo<CR>", "Vimtex Info" },
|
||||||
|
l = {
|
||||||
|
name = "Clean",
|
||||||
|
l = { "<cmd>VimtexClean<CR>", "Clean Project" },
|
||||||
|
c = { "<cmd>VimtexClean<CR>", "Clean Cache" },
|
||||||
|
},
|
||||||
|
c = {
|
||||||
|
name = "Compile",
|
||||||
|
c = { "<cmd>VimtexCompile<CR>", "Compile Project" },
|
||||||
|
o = {
|
||||||
|
"<cmd>VimtexCompileOutput<CR>",
|
||||||
|
"Compile Project and Show Output",
|
||||||
|
},
|
||||||
|
s = { "<cmd>VimtexCompileSS<CR>", "Compile project super fast" },
|
||||||
|
e = { "<cmd>VimtexCompileSelected<CR>", "Compile Selected" },
|
||||||
|
},
|
||||||
|
r = {
|
||||||
|
name = "Reload",
|
||||||
|
r = { "<cmd>VimtexReload<CR>", "Reload" },
|
||||||
|
s = { "<cmd>VimtexReloadState<CR>", "Reload State" },
|
||||||
|
},
|
||||||
|
o = {
|
||||||
|
name = "Stop",
|
||||||
|
p = { "<cmd>VimtexStop<CR>", "Stop" },
|
||||||
|
a = { "<cmd>VimtexStopAll<CR>", "Stop All" },
|
||||||
|
},
|
||||||
|
t = {
|
||||||
|
name = "TOC",
|
||||||
|
o = { "<cmd>VimtexTocOpen<CR>", "Open TOC" },
|
||||||
|
t = { "<cmd>VimtexTocToggle<CR>", "Toggle TOC" },
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in a new issue