a. sudo apt install npm lua-luv-dev lua-lpeg \
libunibilium-dev libutf8proc-dev libluajit-5.1-dev -y
b. 其它的,缺什麼補什麼
lua, tree-sitter
fzf, luarocks(不裝,Checkhealth裡會有WARNING),但它不支援lua 5.5
c. 符號亂碼的話,裝Nerd Font字型:
nerdfonts
下載:
JetBrainsMono Nerd Font
安裝:
font
Terminal:
要選有Nerd Font的字型,所有符號就能正常下載
ex: JetBrainsMono Nerd Font
d. (用cmake build...有相依性問題)
$ make distclean
$ make CMAKE_BUILD_TYPE=Release
$ sudo make install
LazyVim
安裝:
How to Install
Commands for LazyVIM
:checkhealth
:checkhealth mason
:Mason //初始化 Mason.nvim,通過 mason 可以自動裝各種LSP
LazyVim Extras, 剛進去nvim時,壓一下x
/home/ubuntu/.config/nvim/lua/config/options.lua
-- Tab
vim.opt.tabstop = 4 -- number of visual spaces per TAB
vim.opt.softtabstop = 4 -- number of spacesin tab when editing
vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab
vim.opt.expandtab = true -- tabs are spaces, mainly because of python
-- avante.nvim, views can only be fully collapsed with the global statusline
vim.opt.laststatus = 3
vim.bo.modifiable = false //Some plugins or custom configurations might set certain buffers as non-modifiable. Look for settings like:
Quick keyboard map, <leader>:space key
Switch buffer: ]b, [b
Searching for Keywords: <leader> + /
list all symbol: <leader> + c + s/S
- Trace code compile_commands.json, for clangd //A compilation database describes compile commands for a codebase
放在根專案下
a. Makefie:
$ sudo apt install bear
$ bear -- make
b. CMake:
$ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
ex:
.
├── compile_commands.json
├── include
│ └── hello.h
├── Makefile
└── src
├── hello.c
└── main.c
go to implementation(gI),它只會回應:[Fzf-lua] No implementations foundfor kernel
$ make menuconfig
$ make CC=clang
$ python3 ./scripts/clang-tools/gen_compile_commands.py
- avante.nvim Install and Sync
Create or open ~/.config/nvim/lua/plugins/avante.lua and add this:
return {
"yetone/avante.nvim",
event = "VeryLazy",
lazy = false,
version = false, -- Set this to "*" to always pull the latest release version, or set it to false to update to the latest code changes.
opts = {
-- add any opts here
provider = "gemini",
gemini = {
model = "gemini-2.0-flash", --see more modles
timeout = 30000, -- timeout in milliseconds
temperature = 0, -- adjust if needed
max_tokens = 4096,
},
},
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
build = "make",
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
dependencies = {
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
--- The below dependencies are optional,
"echasnovski/mini.pick", -- for file_selector provider mini.pick
"nvim-telescope/telescope.nvim", -- for file_selector provider telescope
"hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
"ibhagwan/fzf-lua", -- for file_selector provider fzf
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
"zbirenbaum/copilot.lua", -- for providers='copilot'
{
-- support for image pasting
"HakonHarnes/img-clip.nvim",
event = "VeryLazy",
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
},
},
{
-- Make sure to set this up properly if you have lazy=true
"MeanderingProgrammer/render-markdown.nvim",
opts = {
file_types = { "markdown", "Avante" },
},
ft = { "markdown", "Avante" },
},
},
}
Usage:(support AI list:~/.local/share/nvim/lazy/avante.nvim/lua/avante/providers/)
1. The sidebar will be divided into 3 sections: Ask, File Name, and Search Results.
Use the <tab> key to switch.
2. <leader>a //show the list in the menu
3. $ export GEMINI_API_KEY=your_key
CMD:
1. AvanteClear //Clear history and reload nvim manually, if "leader a r" didn't work.
-- with lazy.nvim
return {
"LintaoAmons/bookmarks.nvim",
-- tag = "v2.3.0",
dependencies = {
{ "kkharji/sqlite.lua" },
{ "nvim-telescope/telescope.nvim" },
{ "stevearc/dressing.nvim" }, -- optional: better UI
},
config = function()
local opts = {} -- go to the following link to see all the options in the deafult config file
require("bookmarks").setup(opts) -- you must call setup to init sqlite db
end,
keys = {
{ "mm", "<cmd>BookmarksMark<cr>", desc = "Mark current line into active BookmarkList", mode = { "n", "v" } },
{ "mo", "<cmd>BookmarksGoto<cr>", desc = "Go to bookmark at current active BookmarkList", mode = { "n", "v" } },
{ "ml", "<cmd>BookmarksTree<cr>", desc = "Browse bookmarks in tree view", mode = { "n", "v" } },
},
}
-- run :BookmarksInfo to see the running status of the plugin
~/.local/share/nvim/bookmarks.backup/bookmarks_yyyymmdd.sqlite.db,一個約16kB
~/.local/share/nvim/lazy/LazyVim/lua/lazyvim/plugins/extras/dap/core.lua
...
keys = {
{ "<leader>dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" },
{ "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" },
{ "<leader>dc", function() require("dap").continue() end, desc = "Run/Continue" },
...
Useage:
$ gdb -g -Wall gdb_test.c -o gdb_test
lazynvim:
a. key: <leader>db, //toggle breakpoing
b. start: <leader>da //Lanuch file -> Run with args(enter) -> Patch to executable (enter gdb_test)
- 內建bookmark
Delete: :delmarks a-z or :delmarks!
- 莫名升到nvim 0.11後就有問題了, 再用最新版的build後就沒了, 14fb5b1c79f8d9fca5a8f2b341cf6fa2bb775540, NVIM v0.12.0-dev-213+g1670fbee0f
~/.local/share/nvim/lazy/nui.nvim/lua/nui/utils/init.lua:379: Unknown option 'winborder'
先把這段程式註記掉...
-- if _.feature.v0_11 then
-- function _.get_default_winborder()
-- local style = vim.api.nvim_get_option_value("winborder", {})
-- if style == "" then
-- return "none"
-- end
-- return style
-- end
-- end
ref:1. keymaps
2. 使用LazyVim将Neovim打造成强大IDE(常用快捷键)
3. gemini.nvim
沒有留言:
張貼留言