feat(config): add ghostty terminal and refactor neovim configuration
- Add ghostty terminal configuration with custom themes and settings - Add multiple color themes (ayu-dark, catppuccin variants, moonfly) - Configure ghostty appearance: font, opacity, keybindings - Refactor nvim basic setup to use modern vim.opt API - Modernize LSP configuration with LspAttach autocmd - Update nvim-tree configuration for latest API - Simplify codecompanion plugin setup - Pin nvim-treesitter to main branch - Improve sway-dbus script with XDG runtime checks
This commit is contained in:
@@ -1,51 +1,40 @@
|
||||
-- HELPERS ----------------------------------------------------
|
||||
local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd')
|
||||
local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
|
||||
local g = vim.g -- a table to access global variables
|
||||
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
|
||||
local opt = vim.opt
|
||||
|
||||
-- SYNTAX & FILETYPE ------------------------------------------
|
||||
vim.cmd "syntax on"
|
||||
vim.cmd "filetype plugin indent on"
|
||||
|
||||
cmd "syntax on"
|
||||
-- 相對行號顯示
|
||||
-- cmd "set relativenumber"
|
||||
-- 絕對行號顯示
|
||||
-- cmd "set number"
|
||||
-- 混合模式,同時顯示相對行號和絕對行號
|
||||
cmd "set number relativenumber"
|
||||
cmd "set tabstop=2"
|
||||
cmd "set shiftwidth=2"
|
||||
cmd "set expandtab"
|
||||
cmd "set nofoldenable"
|
||||
-- BASIC SETTINGS ---------------------------------------------
|
||||
opt.number = true -- 顯示行號
|
||||
opt.relativenumber = true -- 顯示相對行號
|
||||
opt.tabstop = 2 -- Tab 寬度
|
||||
opt.shiftwidth = 2 -- 縮排寬度
|
||||
opt.expandtab = true -- 將 Tab 轉為空格
|
||||
opt.foldenable = false -- 預設不折疊
|
||||
|
||||
-- always show status
|
||||
cmd "set laststatus=2"
|
||||
opt.laststatus = 2 -- 始終顯示狀態列
|
||||
opt.ruler = true -- 顯示游標位置
|
||||
opt.cursorline = true -- 高亮當前行
|
||||
opt.cursorcolumn = true -- 高亮當前列
|
||||
opt.hlsearch = true -- 高亮搜尋結果
|
||||
opt.wrap = false -- 不自動換行
|
||||
|
||||
-- show cursor position
|
||||
cmd "set ruler"
|
||||
cmd "set cursorline"
|
||||
cmd "set cursorcolumn"
|
||||
cmd "set hlsearch"
|
||||
opt.backspace = { "indent", "eol", "start" }
|
||||
opt.encoding = "utf-8"
|
||||
opt.completeopt = { "menu", "menuone", "noselect" }
|
||||
opt.swapfile = false -- 不產生 swap 檔案
|
||||
opt.mouse = "" -- 禁用滑鼠
|
||||
|
||||
-- no wrap line
|
||||
cmd "set nowrap"
|
||||
opt.background = "dark"
|
||||
|
||||
-- enable backspace
|
||||
cmd "set backspace=indent,eol,start"
|
||||
cmd "set encoding=utf-8"
|
||||
cmd "set completeopt=menu,menuone,noselect"
|
||||
cmd "set noswapfile"
|
||||
cmd "set mouse="
|
||||
|
||||
cmd "set background=dark"
|
||||
|
||||
cmd "filetype indent on"
|
||||
cmd "filetype on"
|
||||
cmd "filetype plugin on"
|
||||
-- 自動命令 (Auto-commands) -----------------------------------
|
||||
|
||||
-- 處理配色方案與背景透明度
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
cmd([[
|
||||
vim.cmd([[
|
||||
highlight clear CursorLine
|
||||
highlight Normal ctermbg=none
|
||||
highlight LineNr ctermbg=none
|
||||
@@ -58,17 +47,16 @@ vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
end,
|
||||
})
|
||||
|
||||
-- chezmoi 自動套用
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
pattern = "~/.local/share/chezmoi/*",
|
||||
pattern = vim.fn.expand("~/.local/share/chezmoi/*"),
|
||||
command = [[ ! chezmoi apply --source-path % ]],
|
||||
})
|
||||
|
||||
vim.diagnostic.get(0, { severity = {
|
||||
vim.diagnostic.severity.ERROR,
|
||||
vim.diagnostic.severity.WARN,
|
||||
} })
|
||||
vim.diagnostic.config({virtual_text = false, signs = true})
|
||||
-- 診斷設定
|
||||
vim.diagnostic.config({ virtual_text = false, signs = true })
|
||||
|
||||
-- 特定語言設定
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "rust",
|
||||
callback = function()
|
||||
|
||||
@@ -30,54 +30,52 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
"ravitemer/mcphub.nvim"
|
||||
},
|
||||
config = function ()
|
||||
local codecompanion = require("codecompanion")
|
||||
codecompanion.setup({
|
||||
ignore_warnings = true,
|
||||
display = {
|
||||
action_palette = {
|
||||
width = 95,
|
||||
height = 10,
|
||||
prompt = "Prompt ",
|
||||
provider = "default",
|
||||
opts = {
|
||||
show_default_actions = true,
|
||||
show_default_prompt_library = true,
|
||||
title = "CodeCompanion actions",
|
||||
},
|
||||
},
|
||||
},
|
||||
memory = {
|
||||
|
||||
codecompanion.setup({
|
||||
ignore_warnings = true,
|
||||
display = {
|
||||
action_palette = {
|
||||
width = 95,
|
||||
height = 10,
|
||||
prompt = "Prompt ",
|
||||
provider = "default",
|
||||
opts = {
|
||||
chat = { enabled = true, },
|
||||
show_default_actions = true,
|
||||
show_default_prompt_library = true,
|
||||
title = "CodeCompanion actions",
|
||||
},
|
||||
},
|
||||
adapters = {
|
||||
http = {
|
||||
copilot = function()
|
||||
return require('codecompanion.adapters').extend('copilot', {
|
||||
schema = {
|
||||
model = {
|
||||
-- default = 'claude-sonnet-4.5',
|
||||
default = 'claude-haiku-4.5',
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
},
|
||||
memory = {
|
||||
opts = {
|
||||
chat = { enabled = true, },
|
||||
},
|
||||
extensions = {
|
||||
mcphub = {
|
||||
callback = "mcphub.extensions.codecompanion",
|
||||
opts = {
|
||||
make_vars = true,
|
||||
make_slash_commands = true,
|
||||
show_result_in_chat = true
|
||||
}
|
||||
}
|
||||
},
|
||||
strategies = {
|
||||
chat = {
|
||||
adapter = "copilot",
|
||||
},
|
||||
inline = {
|
||||
adapter = "copilot",
|
||||
},
|
||||
},
|
||||
adapters = {
|
||||
http = {
|
||||
copilot = function()
|
||||
return require('codecompanion.adapters').extend('copilot', {
|
||||
schema = {
|
||||
model = {
|
||||
default = 'claude-sonnet-4.5',
|
||||
-- default = 'claude-haiku-4.5',
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -75,7 +75,10 @@ return {
|
||||
require('plugins.bufferline'),
|
||||
|
||||
--require('plugins.indent_blankline'),
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = "main",
|
||||
},
|
||||
|
||||
{
|
||||
"bluz71/vim-nightfly-colors",
|
||||
|
||||
@@ -1,100 +1,60 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
config = function ()
|
||||
config = function()
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local on_attach = function (client, bufnr)
|
||||
local lspSig = require('lsp_signature')
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
|
||||
lspSig.on_attach()
|
||||
-- 統一處理 LspAttach (當 LSP 連接到緩衝區時觸發)
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||
callback = function(ev)
|
||||
local bufnr = ev.buf
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
|
||||
-- enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
-- 啟動 lsp_signature
|
||||
require('lsp_signature').on_attach({}, bufnr)
|
||||
|
||||
-- mappings
|
||||
local opts = { noremap=true, silent=true }
|
||||
-- 啟用 omnifunc
|
||||
vim.bo[bufnr].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
-- buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>gt', '<cmd>tab split<CR><cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>gv', '<cmd>vsplit<CR><cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>ge', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>do', '<cmd>lua vim.lsp.diagnostic.open_float()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>d[', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>d]', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>gf', '<cmd>lua vim.lsp.buf.format()<CR>', opts)
|
||||
end
|
||||
-- 按鍵對映優化
|
||||
local opts = { buffer = bufnr, noremap = true, silent = true }
|
||||
local map = vim.keymap.set
|
||||
|
||||
|
||||
vim.lsp.config('gopls', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
vim.lsp.config('ts_ls', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
vim.lsp.config('rust_analyzer', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
vim.lsp.config('bashls', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
vim.lsp.config('svelte', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
vim.lsp.config('pylsp', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
vim.lsp.config('zls', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
vim.lsp.config('lua_ls', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
vim.lsp.config('clangd', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
vim.lsp.config('pyright', {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
map('n', '<leader>gd', vim.lsp.buf.definition, opts)
|
||||
map('n', '<leader>gt', '<cmd>tab split<CR><cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
map('n', '<leader>gv', '<cmd>vsplit<CR><cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
map('n', 'K', vim.lsp.buf.hover, opts)
|
||||
map('n', '<leader>gi', vim.lsp.buf.implementation, opts)
|
||||
map('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||
map('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
||||
map('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
map('n', '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||
map('n', '<leader>gr', vim.lsp.buf.references, opts)
|
||||
map('n', '<leader>ge', vim.diagnostic.open_float, opts) -- 使用現代 API
|
||||
map('n', '<leader>do', vim.diagnostic.open_float, opts)
|
||||
map('n', '<leader>d[', vim.diagnostic.goto_prev, opts)
|
||||
map('n', '<leader>d]', vim.diagnostic.goto_next, opts)
|
||||
map('n', '<leader>gf', function() vim.lsp.buf.format { async = true } end, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
vim.lsp.enable('gopls')
|
||||
vim.lsp.enable('ts_ls')
|
||||
vim.lsp.enable('rust_analyzer')
|
||||
vim.lsp.enable('bashls')
|
||||
vim.lsp.enable('svelte')
|
||||
vim.lsp.enable('pylsp')
|
||||
vim.lsp.enable('zls')
|
||||
vim.lsp.enable('lua_ls')
|
||||
vim.lsp.enable('clangd')
|
||||
vim.lsp.enable('pyright')
|
||||
-- 伺服器列表
|
||||
local servers = {
|
||||
'gopls', 'ts_ls', 'rust_analyzer', 'bashls', 'svelte',
|
||||
'pylsp', 'zls', 'lua_ls', 'clangd', 'pyright'
|
||||
}
|
||||
|
||||
-- 批量配置伺服器能力
|
||||
for _, lsp in ipairs(servers) do
|
||||
vim.lsp.config(lsp, {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end
|
||||
|
||||
-- 批量啟用伺服器
|
||||
vim.lsp.enable(servers)
|
||||
end
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
return {
|
||||
"kyazdani42/nvim-tree.lua",
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
keys = {
|
||||
{"<leader>me", ':NvimTreeToggle<CR>', desc = 'open / close nvim tree', mode = 'n'},
|
||||
{"<F3>", ':NvimTreeToggle<CR>', desc = 'open / close nvim tree', mode = 'n'}
|
||||
{"<leader>me", '<cmd>NvimTreeToggle<CR>', desc = 'open / close nvim tree', mode = 'n'},
|
||||
{"<F3>", '<cmd>NvimTreeToggle<CR>', desc = 'open / close nvim tree', mode = 'n'}
|
||||
},
|
||||
opts = {
|
||||
auto_reload_on_write = true,
|
||||
disable_netrw = false,
|
||||
hijack_cursor = false,
|
||||
hijack_netrw = true,
|
||||
hijack_unnamed_buffer_when_opening = false,
|
||||
open_on_tab = false,
|
||||
sort_by = "name",
|
||||
update_cwd = false,
|
||||
sort = {
|
||||
sorter = "name",
|
||||
},
|
||||
view = {
|
||||
width = 40,
|
||||
side = "left",
|
||||
@@ -27,6 +25,7 @@ return {
|
||||
icons = {
|
||||
corner = "└ ",
|
||||
edge = "│ ",
|
||||
item = "│ ",
|
||||
none = " ",
|
||||
},
|
||||
},
|
||||
@@ -37,13 +36,9 @@ return {
|
||||
},
|
||||
update_focused_file = {
|
||||
enable = false,
|
||||
update_cwd = false,
|
||||
update_root = false,
|
||||
ignore_list = {},
|
||||
},
|
||||
system_open = {
|
||||
cmd = nil,
|
||||
args = {},
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
custom = {},
|
||||
|
||||
Reference in New Issue
Block a user