Skip to content

Commit

Permalink
feat: add ccls lsp config
Browse files Browse the repository at this point in the history
Also update .gitconfig and install scripts
  • Loading branch information
jiangyinzuo committed May 23, 2024
1 parent cdafaea commit ebb8140
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 9 deletions.
4 changes: 2 additions & 2 deletions install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Run `sync-scripts.sh` and `:PlugUpgrade` to sync scripts (optional).

Unofficial PPA for Vim: https://launchpad.net/~jonathonf/+archive/ubuntu/vim

**Build from Source**: `install/build_vim_from_source.sh`
**Build from Source**: `install/build_vim.sh`

### Neovim

Expand All @@ -36,7 +36,7 @@ https://github.com/neovim/neovim/blob/nightly/INSTALL.md#install-from-package

See: https://github.com/neovim/neovim-releases

**Build from Source**: `install/build_nvim_from_source.sh`
**Build from Source**: `install/build_nvim.sh`

### Node.js

Expand Down
16 changes: 16 additions & 0 deletions install/build_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

commit=$1

sudo apt-get -y install libssl-dev

function _uninstall() {
sudo make uninstall
}

function _install() {
./bootstrap && make && sudo make install
}

. install/git.sh
main https://gitlab.kitware.com/cmake/cmake.git cmake $commit
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions install/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ prompt=""

function install_tmux() {
# Ubuntu18.04默认安装tmux2.6
# tmux2.6中,使用fzf的CTRL-R快捷键会卡死,请手动运行 cd ~/vimrc && ./install/build_tmux_from_source.sh安装
# tmux2.6中,使用fzf的CTRL-R快捷键会卡死,请手动运行 cd ~/vimrc && ./install/build_tmux.sh安装
if [[ $UBUNTU_VERSION == "18.04" ]]; then
./install/build_tmux_from_source.sh
./install/build_tmux.sh
else
sudo apt-get install -y tmux
fi
}

function install_nvim() {
if [[ $UBUNTU_VERSION == "18.04" || $UBUNTU_VERSION == "20.04" ]]; then
./install/build_nvim_from_source.sh $NVIM_COMMIT
./install/build_nvim.sh $NVIM_COMMIT
else
sudo add-apt-repository ppa:neovim-ppa/unstable
sudo apt-get install -y neovim
Expand Down Expand Up @@ -78,6 +78,7 @@ function install_git_delta() {
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
prompt=$prompt"
=== git-delta ===
source ~/.bashrc
cargo install git-delta
"
Expand All @@ -89,7 +90,7 @@ function install_vim() {
# sudo update-alternatives --config vim
# update-alternatives --install /usr/bin/vim vim /usr/local/bin/vim 100
sudo apt-get -y install libgtk-3-dev libxt-dev
./install/build_vim_from_source.sh $VIM_COMMIT
./install/build_vim.sh $VIM_COMMIT
}

function install_nvm() {
Expand Down
7 changes: 7 additions & 0 deletions root/.config/nvim/lua/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ local M = {}

local function setup_lsp(on_attach, capabilities)
local lspconfig = require("lspconfig")
if vim.fn.get(vim.g.nvim_lsp_autostart, "ccls", false) then
lspconfig.ccls.setup({
on_attach = on_attach,
capabilities = capabilities,
init_options = vim.g.ccls_init_options,
})
end
if vim.fn.get(vim.g.nvim_lsp_autostart, "clangd", false) then
lspconfig.clangd.setup({
on_attach = on_attach,
Expand Down
2 changes: 2 additions & 0 deletions root/.config/nvim/lua/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ return {
dependencies = { "nvim-lua/plenary.nvim" },
opts = {},
},
-- Alternatives:
-- https://github.com/jedrzejboczar/possession.nvim
{
"rmagatti/auto-session",
opts = {
Expand Down
6 changes: 6 additions & 0 deletions root/.config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ if vim.g.vimrc_lsp == "nvim-lsp" then
},
config = lsp.lspconfig,
},
{
"ranjithshegde/ccls.nvim",
dependencies = {
"neovim/nvim-lspconfig",
},
},
-- 目前缺乏type hierarchy tree UI
{
"nvimdev/lspsaga.nvim",
Expand Down
2 changes: 2 additions & 0 deletions root/.gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
# git tree # all commits
# git tree -2 # last 2 commits
tree = log --graph --decorate --all --pretty=format:'%C(auto,yellow)%h %C(auto,green)%an %C(auto,blue)%ad%C(auto)%d%n%x09%C(reset)%s' --date=format-local:'%Y-%m-%d %H:%M:%S'
oneline = log --oneline --graph --decorate --all
picture = log --oneline --graph --simplify-by-decoration
# git status, but exclude some files
status-ex = "!f() { git ls-files | grep -v \"^$1/\" | xargs git status; }; f"
rm-file-in-history = !git-rm-file-in-history
2 changes: 1 addition & 1 deletion root/.vim/doc/ai.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ https://platform.openai.com/docs/assistants/overview
>
pip install shell-gpt
<
*github-copilot-cli*
*github-copilot-cli* |github-cli|

https://docs.github.com/en/copilot/github-copilot-in-the-cli/using-github-copilot-in-the-cli

Expand Down
16 changes: 15 additions & 1 deletion root/.vim/doc/c-cpp-cuda.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
vim:ft=help
*c-cpp-cuda*

Clangd ~
======================================================================================
LLVM Toolchains

--------------------------------------------------------------------------------------
Clangd

*clangd*

Expand Down Expand Up @@ -43,6 +47,16 @@ output to quickfix list: >
= 延迟赋值,使用到变量的时候才确定变量的值
:= 立即赋值

======================================================================================
Ccls

Oceanbase uses ccls https://github.com/oceanbase/oceanbase/blob/ed4ed014ef2f2a904c64e04331ac4dc1ccf2b778/docs/ide-settings.md

In the C/C++ LSP domain, the famous tools are clangd and ccls. Here we recommend ccls, because:

- The speed of building index of ccls is slower than that of clangd, but after building, the speed of accessing index of ccls is faster than that of clangd.
- Unity building doesn't be supported by clangd, but OceanBase is being built by unity, failed to build index through compile_commands.json by clangd.

======================================================================================
C++包管理器

Expand Down
1 change: 1 addition & 0 deletions root/.vim/doc/code-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ https://github.com/oceanbase/oceanbase/blob/develop/src/rootserver/ob_ddl_servic

- clangd可能会非常慢(显示diagnostic可能需要2-3分钟以上)
- 某些重命名功能可能会失败
- clangd重命名功能可能要等1-2分钟,或者coredump
- 机器内存不够可能导致clangd coredump

或许需要选择性关闭某些功能。
Expand Down
7 changes: 7 additions & 0 deletions root/.vim/doc/gdb-coredump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ thread apply <ID> <command> 对ID线程执行command
gdb查看栈: bt 数字
gdb切换某个栈: f[rame] 数字

-------------------------------------------------------------------------------
*gdb-time-travel*

GDB反向调试:让程序逆序执行,代码调试原来这么简单!体验时光旅行的快感!

https://blog.csdn.net/xzh203/article/details/135820495

-------------------------------------------------------------------------------
ChatGPT

Expand Down
20 changes: 19 additions & 1 deletion root/.vim/doc/git/git-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ https://docs.github.com/zh/authentication/keeping-your-account-and-data-secure/r
*git-fetch*

git只fetch某个远程仓库的某一个分支 >
git fetch origin master
git fetch origin feature
<

git远程仓库某个分支fetch到本地某个分支 >
git fetch origin feature:feature
<

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -359,6 +363,10 @@ git 回滚untracked 修改

-------------------------------------------------------------------------------

*git-clone指定分支*

git clone -b vector_search https://github.com/oceanbase/oceanbase.git --depth=100

*Git在单体仓库中pull部分文件*

*monorepo*
Expand Down Expand Up @@ -508,6 +516,8 @@ NOTE: v0.16.0 后,不再使用 ~/vimrc/tools/rsync-vimrc.sh 同步git仓库。

远程服务器创建非裸仓库,直接在非裸仓库checkout machine/kiwi branch ~

*git-init-vimrc-in-remote-machine*

用例:
远程服务器kiwi连不了外网,本地机器将远程服务器kiwi的`/home/jiangyinzuo/vimrc`
作为远程仓库。本地服务器仅在main分支修改、push main分支,pull
Expand Down Expand Up @@ -634,3 +644,11 @@ hint: git branch -m <name>
*git-mv* *git-grep* git对应的mv grep
===============================================================================

*github-cli*

安装: https://github.com/cli/cli/blob/trunk/docs/install_linux.md

pull并检出github某个pr
>
gh pr checkout https://github.com/milvus-io/milvus/pull/33173
<
9 changes: 9 additions & 0 deletions root/.vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ if has('autocmd') " vim-tiny does not have autocmd
else
let g:vimrc_lsp = get(g:, 'vimrc_lsp', 'coc.nvim')
endif
let g:ccls_init_options = {
\ "compilationDatabaseDirectory": "build",
\ "index": {
\ "threads": 0
\ },
\ "clang": {
\ "excludeArgs": ["-frounding-math"],
\ }
\}

" tmux2.2以上才支持true color
let g:vimrc_use_true_color = get(g:, 'vimrc_use_true_color', 1)
Expand Down

0 comments on commit ebb8140

Please sign in to comment.