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:
@@ -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