wip
This commit is contained in:
@@ -1 +0,0 @@
|
||||
Until changes are fixed with main neovim repo, use my neovim repo that was patched to have the package manager work with my init.
|
||||
File diff suppressed because it is too large
Load Diff
+24
-54
@@ -1,64 +1,34 @@
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", "https://github.com/folke/lazy.nvim.git", lazypath })
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", "https://github.com/folke/lazy.nvim.git", lazypath })
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
vim.g.mapleader = " "
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
"neovim/nvim-lspconfig",
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"cohama/lexima.vim",
|
||||
"DarthMoomancer/Polydev",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
"nvim-lua/plenary.nvim",
|
||||
{ "saghen/blink.cmp", version = "v1.*", opts = {
|
||||
completion = {
|
||||
ghost_text = {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
checker = { enabled = true },
|
||||
},
|
||||
spec = {
|
||||
"cohama/lexima.vim",
|
||||
{ "echasnovski/mini.pick", version = '*' },
|
||||
{ "saghen/blink.cmp", version = "v1.*", opts = {} },
|
||||
}
|
||||
})
|
||||
vim.opt.mouse = ""
|
||||
vim.opt.completeopt = "noselect"
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.wrap = false
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.sidescrolloff = 8
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.clipboard = unnamedplus
|
||||
require('mini.pick').setup()
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.o.termguicolors = true
|
||||
vim.o.number = true
|
||||
vim.o.relativenumber = true
|
||||
vim.o.wrap = false
|
||||
vim.o.swapfile = false
|
||||
vim.o.signcolumn = "yes"
|
||||
vim.o.scrolloff = 8
|
||||
vim.o.sidescrolloff = 8
|
||||
vim.o.hlsearch = false
|
||||
vim.o.completeopt = { "menuone", "noselect", "popup" }
|
||||
|
||||
vim.lsp.enable({ "lua_ls", "clangd" })
|
||||
vim.cmd.colorscheme('everforest')
|
||||
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
vim.keymap.set("x", "<leader>p", [["_dP]])
|
||||
vim.keymap.set("n", "<leader>ff", "gg=G")
|
||||
vim.keymap.set('n', '<leader><leader>', ":Telescope find_files<CR>", { desc = 'Telescope find files' })
|
||||
vim.keymap.set('n', '<leader>xg', ":Telescope live_grep<CR>", { desc = 'Telescope live grep' })
|
||||
vim.keymap.set('n', '<leader>xh', ":Telescope help_tags<CR>", { desc = 'Telescope help tags' })
|
||||
vim.keymap.set("n", "<leader>xc", "<Cmd>cclose<CR>")
|
||||
vim.keymap.set("n", "<leader>xx", function()
|
||||
vim.diagnostic.setqflist({ open = true })
|
||||
end, { desc = "Show diagnostics in quickfix" })
|
||||
|
||||
vim.cmd.colorscheme('everforest')
|
||||
vim.lsp.enable({ "lua_ls", "clangd" })
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "qf",
|
||||
callback = function()
|
||||
vim.api.nvim_buf_set_keymap(0, "n", "<CR>", "<CR>:cclose<CR>", { noremap = true, silent = true })
|
||||
end,
|
||||
})
|
||||
|
||||
require("nvim-treesitter.configs").setup({
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true }
|
||||
})
|
||||
vim.keymap.set("n", "<leader>ff", "ggVG=")
|
||||
vim.keymap.set('n', '<leader><leader>', ":Pick files<CR>")
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
---@brief
|
||||
---
|
||||
--- https://clangd.llvm.org/installation.html
|
||||
---
|
||||
--- - **NOTE:** Clang >= 11 is recommended! See [#23](https://github.com/neovim/nvim-lspconfig/issues/23).
|
||||
--- - If `compile_commands.json` lives in a build directory, you should
|
||||
--- symlink it to the root of your source tree.
|
||||
--- ```
|
||||
--- ln -s /path/to/myproject/build/compile_commands.json /path/to/myproject/
|
||||
--- ```
|
||||
--- - clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
|
||||
--- specified as compile_commands.json, see https://clangd.llvm.org/installation#compile_commandsjson
|
||||
|
||||
-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
|
||||
local function switch_source_header(bufnr)
|
||||
local method_name = 'textDocument/switchSourceHeader'
|
||||
local client = vim.lsp.get_clients({ bufnr = bufnr, name = 'clangd' })[1]
|
||||
if not client then
|
||||
return vim.notify(('method %s is not supported by any servers active on the current buffer'):format(method_name))
|
||||
end
|
||||
local params = vim.lsp.util.make_text_document_params(bufnr)
|
||||
client.request(method_name, params, function(err, result)
|
||||
if err then
|
||||
error(tostring(err))
|
||||
end
|
||||
if not result then
|
||||
vim.notify('corresponding file cannot be determined')
|
||||
return
|
||||
end
|
||||
vim.cmd.edit(vim.uri_to_fname(result))
|
||||
end, bufnr)
|
||||
end
|
||||
|
||||
local function symbol_info()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
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
|
||||
return vim.notify('Clangd client not found', vim.log.levels.ERROR)
|
||||
end
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
local params = vim.lsp.util.make_position_params(win, clangd_client.offset_encoding)
|
||||
clangd_client.request('textDocument/symbolInfo', params, function(err, res)
|
||||
if err or #res == 0 then
|
||||
-- Clangd always returns an error, there is not reason to parse it
|
||||
return
|
||||
end
|
||||
local container = string.format('container: %s', res[1].containerName) ---@type string
|
||||
local name = string.format('name: %s', res[1].name) ---@type string
|
||||
vim.lsp.util.open_floating_preview({ name, container }, '', {
|
||||
height = 2,
|
||||
width = math.max(string.len(name), string.len(container)),
|
||||
focusable = false,
|
||||
focus = false,
|
||||
border = 'single',
|
||||
title = 'Symbol Info',
|
||||
})
|
||||
end, bufnr)
|
||||
end
|
||||
|
||||
---@class ClangdInitializeResult: lsp.InitializeResult
|
||||
---@field offsetEncoding? string
|
||||
|
||||
return {
|
||||
cmd = { 'clangd' },
|
||||
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
|
||||
root_markers = {
|
||||
'.clangd',
|
||||
'.clang-tidy',
|
||||
'.clang-format',
|
||||
'compile_commands.json',
|
||||
'compile_flags.txt',
|
||||
'configure.ac', -- AutoTools
|
||||
'.git',
|
||||
},
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
completion = {
|
||||
editsNearCursor = true,
|
||||
},
|
||||
},
|
||||
offsetEncoding = { 'utf-8', 'utf-16' },
|
||||
},
|
||||
---@param client vim.lsp.Client
|
||||
---@param init_result ClangdInitializeResult
|
||||
on_init = function(client, init_result)
|
||||
if init_result.offsetEncoding then
|
||||
client.offset_encoding = init_result.offsetEncoding
|
||||
end
|
||||
end,
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdSwitchSourceHeader', function()
|
||||
switch_source_header(bufnr)
|
||||
end, { desc = 'Switch between source/header' })
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdShowSymbolInfo', function()
|
||||
symbol_info()
|
||||
end, { desc = 'Show symbol info' })
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
return {
|
||||
cmd = { 'lua-language-server' },
|
||||
filetypes = { 'lua' },
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" }
|
||||
}
|
||||
}
|
||||
},
|
||||
root_markers = {
|
||||
'.luarc.json',
|
||||
'.luarc.jsonc',
|
||||
'.luacheckrc',
|
||||
'.stylua.toml',
|
||||
'stylua.toml',
|
||||
'selene.toml',
|
||||
'selene.yml',
|
||||
'.git',
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user