update
This commit is contained in:
parent
8a48804f48
commit
3b93f35597
17 changed files with 267 additions and 142 deletions
10
lina/.zshrc
10
lina/.zshrc
|
|
@ -50,6 +50,7 @@ alias .....='c ../../../../'
|
||||||
alias ......='c ../../../../../'
|
alias ......='c ../../../../../'
|
||||||
alias gs='cgs'
|
alias gs='cgs'
|
||||||
alias trans='xprop -format _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY 0xEFFFFFFF'
|
alias trans='xprop -format _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY 0xEFFFFFFF'
|
||||||
|
alias neovide='nohup neovide --frame none &'
|
||||||
|
|
||||||
c () { cd ${1:-.} ; clear ; l }
|
c () { cd ${1:-.} ; clear ; l }
|
||||||
ca () { cd ${1:-.} ; clear ; la }
|
ca () { cd ${1:-.} ; clear ; la }
|
||||||
|
|
@ -62,8 +63,7 @@ picomadd() { sed -i '/# OPACITY_RULE/i ,"100:name *= '\'$1\''"' ~/.config/picom/
|
||||||
activate()
|
activate()
|
||||||
{
|
{
|
||||||
if [[ "$1" == "light" ]]; then
|
if [[ "$1" == "light" ]]; then
|
||||||
source ${HOME}/dev/python_envs/light/bin/activate #Python
|
source "${HOME}/dev/vulkan_sdk_1.4.321.1/setup-env.sh"
|
||||||
source ${HOME}/dev/1.4.321.1/setup-env.sh # Vulkan
|
|
||||||
PROMPT="%F{green}%n@%m%f %~ $ "
|
PROMPT="%F{green}%n@%m%f %~ $ "
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
|
@ -113,4 +113,8 @@ jade() # Jade is the name of the lofi girl
|
||||||
mpv --no-video $radio
|
mpv --no-video $radio
|
||||||
}
|
}
|
||||||
|
|
||||||
clear ; hyfetch
|
drone_runner()
|
||||||
|
{
|
||||||
|
cd ${HOME}/dev/linux_amd64/
|
||||||
|
sudo docker-compose up
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"LuaSnip": { "branch": "master", "commit": "de10d8414235b0a8cabfeba60d07c24304e71f5c" },
|
"LuaSnip": { "branch": "master", "commit": "21e9fecfc07fb2cd707b6c7c3fa148550a34d053" },
|
||||||
"alpha-nvim": { "branch": "main", "commit": "2b3cbcdd980cae1e022409289245053f62fb50f6" },
|
"alpha-nvim": { "branch": "main", "commit": "2b3cbcdd980cae1e022409289245053f62fb50f6" },
|
||||||
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
||||||
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
|
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
|
||||||
|
|
@ -7,17 +7,17 @@
|
||||||
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
|
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
|
||||||
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||||
"gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" },
|
"gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" },
|
||||||
"gruvbox.nvim": { "branch": "main", "commit": "12c2624287dc827edb5d72b2bc4c9619e692a554" },
|
"gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" },
|
||||||
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
|
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
|
||||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
"lazy.nvim": { "branch": "main", "commit": "1ea3c4085785f460fb0e46d2fe1ee895f5f9e7c1" },
|
||||||
"lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" },
|
"lualine.nvim": { "branch": "master", "commit": "3946f0122255bc377d14a59b27b609fb3ab25768" },
|
||||||
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
|
"nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" },
|
||||||
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
|
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "16878c7a018cba66a6e990286bdb6afc29ca13d3" },
|
"nvim-lspconfig": { "branch": "master", "commit": "ac98db2f9f06a56498ec890a96928774eae412c3" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "b70a741f5a29a1d2baa3bbe7e5c0a4a5d6423849" },
|
"nvim-tree.lua": { "branch": "master", "commit": "e397756d2a79d74314ea4cd3efc41300e91c0ff0" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "c2599a81ecabaae07c49ff9b45dcd032a8d90f1a" },
|
"nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||||
"telescope-args.nvim": { "branch": "main", "commit": "995072920fae8e1bf31daed015114bd54617079a" },
|
"telescope-args.nvim": { "branch": "main", "commit": "995072920fae8e1bf31daed015114bd54617079a" },
|
||||||
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
|
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ keymap(
|
||||||
keymap("n", "<leader>tg", "<cmd>Telescope live_grep<cr>", opts)
|
keymap("n", "<leader>tg", "<cmd>Telescope live_grep<cr>", opts)
|
||||||
|
|
||||||
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>w", "<cmd>lua vim.lsp.buf.format({async = false})<cr><cmd>w<cr>", opts)
|
vim.api.nvim_set_keymap("n", "<leader>w", "<cmd>lua vim.lsp.buf.format({async = false})<cr><cmd>w!<cr>", opts)
|
||||||
keymap("n", "<leader>c", "<cmd>bdelete<cr>", opts)
|
keymap("n", "<leader>c", "<cmd>bdelete<cr>", opts)
|
||||||
|
|
||||||
keymap(
|
keymap(
|
||||||
|
|
|
||||||
|
|
@ -1,78 +1,3 @@
|
||||||
local function supported_by_prettier(filetype)
|
|
||||||
local filetypes = {
|
|
||||||
'javascript',
|
|
||||||
'javascriptreact',
|
|
||||||
'javascript.jsx',
|
|
||||||
'typescript',
|
|
||||||
'typescriptreact',
|
|
||||||
'typescript.tsx',
|
|
||||||
'vue',
|
|
||||||
'svelte',
|
|
||||||
'astro',
|
|
||||||
-- html
|
|
||||||
'aspnetcorerazor',
|
|
||||||
'astro',
|
|
||||||
'astro-markdown',
|
|
||||||
'blade',
|
|
||||||
'clojure',
|
|
||||||
'django-html',
|
|
||||||
'htmldjango',
|
|
||||||
'edge',
|
|
||||||
'eelixir', -- vim ft
|
|
||||||
'elixir',
|
|
||||||
'ejs',
|
|
||||||
'erb',
|
|
||||||
'eruby', -- vim ft
|
|
||||||
'gohtml',
|
|
||||||
'gohtmltmpl',
|
|
||||||
'haml',
|
|
||||||
'handlebars',
|
|
||||||
'hbs',
|
|
||||||
'html',
|
|
||||||
'htmlangular',
|
|
||||||
'html-eex',
|
|
||||||
'heex',
|
|
||||||
'jade',
|
|
||||||
'leaf',
|
|
||||||
'liquid',
|
|
||||||
'markdown',
|
|
||||||
'mdx',
|
|
||||||
'mustache',
|
|
||||||
'njk',
|
|
||||||
'nunjucks',
|
|
||||||
'php',
|
|
||||||
'razor',
|
|
||||||
'slim',
|
|
||||||
'twig',
|
|
||||||
-- css
|
|
||||||
'css',
|
|
||||||
'less',
|
|
||||||
'postcss',
|
|
||||||
'sass',
|
|
||||||
'scss',
|
|
||||||
'stylus',
|
|
||||||
'sugarss',
|
|
||||||
-- js
|
|
||||||
'javascript',
|
|
||||||
'javascriptreact',
|
|
||||||
'reason',
|
|
||||||
'rescript',
|
|
||||||
'typescript',
|
|
||||||
'typescriptreact',
|
|
||||||
-- mixed
|
|
||||||
'vue',
|
|
||||||
'svelte',
|
|
||||||
'templ',
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v in ipairs(filetypes) do
|
|
||||||
if v == filetype then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
virtual_text = true,
|
virtual_text = true,
|
||||||
signs = {
|
signs = {
|
||||||
|
|
@ -104,17 +29,28 @@ vim.filetype.add({
|
||||||
|
|
||||||
vim.diagnostic.config(config)
|
vim.diagnostic.config(config)
|
||||||
|
|
||||||
|
vim.lsp.config("clangd", require("lsp/clangd"))
|
||||||
|
vim.lsp.config("luals", require("lsp/lua_ls"))
|
||||||
|
vim.lsp.config("mdx_analyzer", require("lsp/mdx_analyzer"))
|
||||||
|
vim.lsp.config("pyright", require("lsp/pyright"))
|
||||||
|
vim.lsp.config("svelte", require("lsp/svelte"))
|
||||||
|
vim.lsp.config("tailwindcss", require("lsp/tailwindcss"))
|
||||||
|
vim.lsp.config("ts_ls", require("lsp/ts_ls"))
|
||||||
|
vim.lsp.config("cmake", require("lsp/cmake"))
|
||||||
|
vim.lsp.config("bash", require("lsp/bash"))
|
||||||
vim.lsp.buf.hover({ border = "rounded" })
|
vim.lsp.buf.hover({ border = "rounded" })
|
||||||
vim.lsp.buf.signature_help({ border = "rounded" })
|
vim.lsp.buf.signature_help({ border = "rounded" })
|
||||||
vim.lsp.enable({
|
vim.lsp.enable({
|
||||||
|
'cmake',
|
||||||
|
|
||||||
|
'bash',
|
||||||
|
|
||||||
'clangd',
|
'clangd',
|
||||||
'luals',
|
'luals',
|
||||||
|
|
||||||
'svelte',
|
'svelte',
|
||||||
'tailwindcss',
|
'tailwindcss',
|
||||||
"ts_ls",
|
"ts_ls",
|
||||||
"cssls",
|
|
||||||
"eslint",
|
|
||||||
"mdx_analyzer",
|
"mdx_analyzer",
|
||||||
|
|
||||||
"pyright",
|
"pyright",
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ nvim_tree.setup({
|
||||||
open_file = {
|
open_file = {
|
||||||
quit_on_open = true,
|
quit_on_open = true,
|
||||||
},
|
},
|
||||||
|
change_dir = {
|
||||||
|
global = true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
update_focused_file = {
|
update_focused_file = {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ vim.opt.shortmess:append("c")
|
||||||
vim.opt.laststatus = 1
|
vim.opt.laststatus = 1
|
||||||
vim.cmd('let g:neovide_cursor_vfx_mode = "pixiedust"')
|
vim.cmd('let g:neovide_cursor_vfx_mode = "pixiedust"')
|
||||||
vim.cmd("let g:neovide_cursor_vfx_particle_density = 32.0")
|
vim.cmd("let g:neovide_cursor_vfx_particle_density = 32.0")
|
||||||
|
vim.diagnostic.config({ virtual_text = false, virtual_lines = { current_line = false }, })
|
||||||
|
|
||||||
-- lastplace
|
-- lastplace
|
||||||
vim.api.nvim_create_autocmd('BufReadPost', {
|
vim.api.nvim_create_autocmd('BufReadPost', {
|
||||||
|
|
|
||||||
87
lina/nvim/lua/lsp/bash.lua
Normal file
87
lina/nvim/lua/lsp/bash.lua
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
-- ~/.config/nvim/lua/lsp/servers/bash.lua
|
||||||
|
-- Full bash LSP config (with keymaps, highlights, and shfmt formatter)
|
||||||
|
|
||||||
|
-- Highlighting function
|
||||||
|
local function lsp_highlight_document(client)
|
||||||
|
if client.server_capabilities.documentHighlightProvider then
|
||||||
|
local group = vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("CursorHold", {
|
||||||
|
group = group,
|
||||||
|
buffer = 0,
|
||||||
|
callback = vim.lsp.buf.document_highlight,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||||
|
group = group,
|
||||||
|
buffer = 0,
|
||||||
|
callback = vim.lsp.buf.clear_references,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- LSP keymaps (includes shfmt shortcut)
|
||||||
|
local function lsp_keymaps(bufnr)
|
||||||
|
local opts = { remap = true, silent = true, buffer = bufnr }
|
||||||
|
|
||||||
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||||
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
||||||
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||||
|
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||||
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||||
|
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_prev({ border = "rounded" }) end, opts)
|
||||||
|
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_next({ border = "rounded" }) end, opts)
|
||||||
|
vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, opts)
|
||||||
|
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
|
-- Telescope integration if installed
|
||||||
|
pcall(function()
|
||||||
|
vim.keymap.set("n", "<leader>td", "<cmd>Telescope diagnostics<cr>", opts)
|
||||||
|
vim.keymap.set("n", "<leader>tr", "<cmd>Telescope lsp_references<cr>", opts)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Capabilities (with cmp-nvim-lsp if available)
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
local ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
|
if ok then
|
||||||
|
capabilities = cmp_nvim_lsp.default_capabilities(capabilities)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Return the full bash-language-server config
|
||||||
|
return {
|
||||||
|
cmd = { "bash-language-server", "start" },
|
||||||
|
filetypes = { "bash", "sh" },
|
||||||
|
root_markers = {
|
||||||
|
'.git',
|
||||||
|
'.clangd',
|
||||||
|
'.clang-tidy',
|
||||||
|
'.clang-format',
|
||||||
|
'compile_commands.json',
|
||||||
|
'compile_flags.txt',
|
||||||
|
'configure.ac', -- AutoTools
|
||||||
|
},
|
||||||
|
single_file_support = true,
|
||||||
|
settings = {
|
||||||
|
bashIde = {
|
||||||
|
globPattern = vim.env.GLOB_PATTERN or "*@(.sh|.inc|.bash|.command)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
vim.notify("ON ATTACH")
|
||||||
|
lsp_keymaps(bufnr)
|
||||||
|
lsp_highlight_document(client)
|
||||||
|
|
||||||
|
local augroup = vim.api.nvim_create_augroup('LspFormatting', { clear = true })
|
||||||
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
group = augroup,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
vim.cmd([[silent! !shfmt -w -i 4 -ci %]])
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
capabilities = capabilities,
|
||||||
|
}
|
||||||
|
|
@ -14,30 +14,28 @@ local function lsp_highlight_document(client)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function lsp_keymaps(bufnr)
|
local function lsp_keymaps(bufnr)
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||||
|
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({border="rounded"})<CR>', opts)
|
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_prev({ border = "rounded" }) end, opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({border="rounded"})<CR>', opts)
|
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_next({ border = "rounded" }) end, opts)
|
||||||
|
vim.keymap.set("n", "<M-o>", "<cmd>LspClangdSwitchSourceHeader<cr>", opts)
|
||||||
|
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
|
vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, opts)
|
||||||
|
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
vim.keymap.set(
|
||||||
|
|
||||||
vim.api.nvim_buf_set_keymap(
|
|
||||||
bufnr,
|
|
||||||
"n",
|
"n",
|
||||||
"<leader>td",
|
"<leader>td",
|
||||||
"<cmd>lua require 'telescope.builtin'.diagnostics()<cr>",
|
"<cmd>lua require 'telescope.builtin'.diagnostics()<cr>",
|
||||||
opts
|
opts
|
||||||
)
|
)
|
||||||
vim.api.nvim_buf_set_keymap(
|
vim.keymap.set(
|
||||||
bufnr,
|
|
||||||
"n",
|
"n",
|
||||||
"<leader>tr",
|
"<leader>tr",
|
||||||
"<cmd>lua require 'telescope.builtin'.lsp_references()<CR>",
|
"<cmd>lua require 'telescope.builtin'.lsp_references()<CR>",
|
||||||
|
|
@ -52,9 +50,9 @@ if not status_ok then
|
||||||
end
|
end
|
||||||
|
|
||||||
local client_capabilities = vim.lsp.protocol.make_client_capabilities()
|
local client_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
local capabilities = cmp_nvim_lsp.default_capabilities(client_capabilities)
|
-- local capabilities = cmp_nvim_lsp.default_capabilities(client_capabilities)
|
||||||
capabilities.offsetEncoding = { "utf-8", "utf-16" }
|
-- capabilities.textDocument.completion.editsNearCursor = true
|
||||||
capabilities.textDocument.completion.editsNearCursor = true
|
-- table.remove(capabilities, capabilities.offsetEncoding)
|
||||||
|
|
||||||
---@brief
|
---@brief
|
||||||
---
|
---
|
||||||
|
|
@ -89,35 +87,34 @@ local function switch_source_header(bufnr)
|
||||||
end, bufnr)
|
end, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function symbol_info()
|
-- local function symbol_info()
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
-- local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local clangd_client = vim.lsp.get_clients({ bufnr = bufnr, name = 'clangd' })[1]
|
-- local clangd_client = vim.lsp.get_clients({ bufnr = bufnr, name = 'clangd' })[1]
|
||||||
if not clangd_client or not clangd_client.supports_method 'textDocument/symbolInfo' then
|
-- if not clangd_client or not clangd_client.supports_method 'textDocument/symbolInfo' then
|
||||||
return vim.notify('Clangd client not found', vim.log.levels.ERROR)
|
-- return vim.notify('Clangd client not found', vim.log.levels.ERROR)
|
||||||
end
|
-- end
|
||||||
local win = vim.api.nvim_get_current_win()
|
-- local win = vim.api.nvim_get_current_win()
|
||||||
local params = vim.lsp.util.make_position_params(win, clangd_client.offset_encoding)
|
-- local params = vim.lsp.util.make_position_params(win, clangd_client.offset_encoding)
|
||||||
clangd_client.request('textDocument/symbolInfo', params, function(err, res)
|
-- clangd_client.request('textDocument/symbolInfo', params, function(err, res)
|
||||||
if err or #res == 0 then
|
-- if err or #res == 0 then
|
||||||
-- Clangd always returns an error, there is not reason to parse it
|
-- -- Clangd always returns an error, there is not reason to parse it
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
local container = string.format('container: %s', res[1].containerName) ---@type string
|
-- local container = string.format('container: %s', res[1].containerName) ---@type string
|
||||||
local name = string.format('name: %s', res[1].name) ---@type string
|
-- local name = string.format('name: %s', res[1].name) ---@type string
|
||||||
vim.lsp.util.open_floating_preview({ name, container }, '', {
|
-- vim.lsp.util.open_floating_preview({ name, container }, '', {
|
||||||
height = 2,
|
-- height = 2,
|
||||||
width = math.max(string.len(name), string.len(container)),
|
-- width = math.max(string.len(name), string.len(container)),
|
||||||
focusable = false,
|
-- focusable = false,
|
||||||
focus = false,
|
-- focus = false,
|
||||||
border = 'single',
|
-- border = 'single',
|
||||||
title = 'Symbol Info',
|
-- title = 'Symbol Info',
|
||||||
})
|
-- })
|
||||||
end, bufnr)
|
-- end, bufnr)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cmd = { 'clangd' },
|
cmd = { "/home/light/dev/clangd/clangd_snapshot_20250928/bin/clangd", },
|
||||||
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda', 'proto' },
|
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda', 'proto', },
|
||||||
root_markers = {
|
root_markers = {
|
||||||
'.clangd',
|
'.clangd',
|
||||||
'.clang-tidy',
|
'.clang-tidy',
|
||||||
|
|
@ -127,11 +124,13 @@ return {
|
||||||
'configure.ac', -- AutoTools
|
'configure.ac', -- AutoTools
|
||||||
'.git',
|
'.git',
|
||||||
},
|
},
|
||||||
capabilities = capabilities,
|
capabilities = client_capabilities,
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
|
vim.notify("ON ATTACH")
|
||||||
lsp_keymaps(bufnr)
|
lsp_keymaps(bufnr)
|
||||||
lsp_highlight_document(client)
|
lsp_highlight_document(client)
|
||||||
|
|
||||||
|
local augroup = vim.api.nvim_create_augroup('LspFormatting', { clear = true })
|
||||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
group = augroup,
|
group = augroup,
|
||||||
|
|
@ -145,8 +144,8 @@ return {
|
||||||
switch_source_header(0)
|
switch_source_header(0)
|
||||||
end, { desc = 'Switch between source/header' })
|
end, { desc = 'Switch between source/header' })
|
||||||
|
|
||||||
vim.api.nvim_buf_create_user_command(0, 'LspClangdShowSymbolInfo', function()
|
-- vim.api.nvim_buf_create_user_command(0, 'LspClangdShowSymbolInfo', function()
|
||||||
symbol_info()
|
-- symbol_info()
|
||||||
end, { desc = 'Show symbol info' })
|
-- end, { desc = 'Show symbol info' })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
95
lina/nvim/lua/lsp/cmake.lua
Normal file
95
lina/nvim/lua/lsp/cmake.lua
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
local function lsp_highlight_document(client)
|
||||||
|
if client.server_capabilities.document_highlight then
|
||||||
|
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("CursorHold", {
|
||||||
|
group = "lsp_document_highlight",
|
||||||
|
buffer = 0,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.document_highlight()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||||
|
group = "lsp_document_highlight",
|
||||||
|
buffer = 0,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.clear_references()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function lsp_keymaps(bufnr)
|
||||||
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({border="rounded"})<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({border="rounded"})<CR>', opts)
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_keymap(
|
||||||
|
bufnr,
|
||||||
|
"n",
|
||||||
|
"<leader>td",
|
||||||
|
"<cmd>lua require 'telescope.builtin'.diagnostics()<cr>",
|
||||||
|
opts
|
||||||
|
)
|
||||||
|
vim.api.nvim_buf_set_keymap(
|
||||||
|
bufnr,
|
||||||
|
"n",
|
||||||
|
"<leader>tr",
|
||||||
|
"<cmd>lua require 'telescope.builtin'.lsp_references()<CR>",
|
||||||
|
opts
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
|
if not status_ok then
|
||||||
|
print("Failed to require cmp_nvim_lsp")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local client_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
local capabilities = cmp_nvim_lsp.default_capabilities(client_capabilities)
|
||||||
|
local util = require 'lspconfig.util'
|
||||||
|
return {
|
||||||
|
default_config = {
|
||||||
|
cmd = { 'cmake-language-server' },
|
||||||
|
filetypes = { 'cmake' },
|
||||||
|
root_dir = function(fname)
|
||||||
|
return util.root_pattern('CMakePresets.json', 'CTestConfig.cmake', '.git', 'build', 'cmake')(fname)
|
||||||
|
end,
|
||||||
|
single_file_support = true,
|
||||||
|
init_options = {
|
||||||
|
buildDirectory = 'build',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
docs = {
|
||||||
|
description = [[
|
||||||
|
https://github.com/regen100/cmake-language-server
|
||||||
|
|
||||||
|
CMake LSP Implementation
|
||||||
|
]],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue