codecompanion
This commit is contained in:
parent
239756d583
commit
97110bcaad
2
init.vim
2
init.vim
@ -35,11 +35,11 @@ source ~/.config/nvim/plugin-confs/lsplines.lua
|
|||||||
source ~/.config/nvim/plugin-confs/null-ls.lua
|
source ~/.config/nvim/plugin-confs/null-ls.lua
|
||||||
source ~/.config/nvim/plugin-confs/lsp-format.lua
|
source ~/.config/nvim/plugin-confs/lsp-format.lua
|
||||||
source ~/.config/nvim/plugin-confs/nvim-cmp.lua
|
source ~/.config/nvim/plugin-confs/nvim-cmp.lua
|
||||||
|
source ~/.config/nvim/plugin-confs/codecompanion.lua
|
||||||
source ~/.config/nvim/plugin-confs/luasnip.lua
|
source ~/.config/nvim/plugin-confs/luasnip.lua
|
||||||
source ~/.config/nvim/plugin-confs/fidget.lua
|
source ~/.config/nvim/plugin-confs/fidget.lua
|
||||||
source ~/.config/nvim/plugin-confs/rainbow-delimiters.lua
|
source ~/.config/nvim/plugin-confs/rainbow-delimiters.lua
|
||||||
" source ~/.config/nvim/plugin-confs/symbols-outline.lua
|
" source ~/.config/nvim/plugin-confs/symbols-outline.lua
|
||||||
" source ~/.config/nvim/plugin-confs/chatgpt.lua
|
|
||||||
source ~/.config/nvim/plugin-confs/nvim-colorizer.lua
|
source ~/.config/nvim/plugin-confs/nvim-colorizer.lua
|
||||||
source ~/.config/nvim/plugin-confs/nvim-dap-python.lua
|
source ~/.config/nvim/plugin-confs/nvim-dap-python.lua
|
||||||
source ~/.config/nvim/plugin-confs/nvim-dap-bash.lua
|
source ~/.config/nvim/plugin-confs/nvim-dap-bash.lua
|
||||||
|
@ -54,25 +54,23 @@ nnoremap <leader>bp :bprev<CR>
|
|||||||
|
|
||||||
nnoremap <leader>ca :lua vim.lsp.buf.code_action()<CR>
|
nnoremap <leader>ca :lua vim.lsp.buf.code_action()<CR>
|
||||||
nnoremap <leader>cA :lua vim.lsp.buf.code_action()<CR>
|
nnoremap <leader>cA :lua vim.lsp.buf.code_action()<CR>
|
||||||
|
nnoremap <leader>cc :CodeCompanionChat<CR>
|
||||||
|
nnoremap <leader>ci :CodeCompanion
|
||||||
nnoremap <leader>cd :Telescope diagnostics<CR>
|
nnoremap <leader>cd :Telescope diagnostics<CR>
|
||||||
nnoremap <leader>cDn :lua vim.diagnostic.goto_next()<CR>
|
nnoremap <leader>cDn :lua vim.diagnostic.goto_next()<CR>
|
||||||
nnoremap <leader>cDp :lua vim.diagnostic.goto_prev()<CR>
|
nnoremap <leader>cDp :lua vim.diagnostic.goto_prev()<CR>
|
||||||
nnoremap <leader>cl :lua vim.diagnostic.setloclist()<CR>
|
nnoremap <leader>cl :lua vim.diagnostic.setloclist()<CR>
|
||||||
nnoremap <silent> <leader>cp :vert Copilot panel<CR>
|
nnoremap <silent> <leader>cp :vert Copilot panel<CR>
|
||||||
nnoremap <silent> <leader>Ci :lua require('chatgpt').edit_with_instructions()<CR>
|
nnoremap <leader>Ca :CodeCompanionActions<CR>
|
||||||
nnoremap <silent> <leader>Cd :ChatGPTRun docstring<CR>
|
nnoremap <leader>Cc :CodeCompanionChat<CR>
|
||||||
nnoremap <silent> <leader>Ct :ChatGPTRun add_tests<CR>
|
nnoremap <leader>Cc :CodeCompanionChat<CR>
|
||||||
nnoremap <silent> <leader>Co :ChatGPTRun optimize_code<CR>
|
nnoremap <leader>Ci :CodeCompanion
|
||||||
nnoremap <silent> <leader>Cs :ChatGPTRun summarize<CR>
|
nnoremap <leader>Ct :CodeCompanionChat Toggle<CR>
|
||||||
nnoremap <silent> <leader>Cf :ChatGPTRun fix_bugs<CR>
|
vnoremap <leader>Cc :CodeCompanionChat Add<CR>
|
||||||
nnoremap <silent> <leader>Ce :ChatGPTRun explain_code<CR>
|
vnoremap <leader>Ce :CodeCompanion /explain<CR>
|
||||||
xnoremap <silent> <leader>Ci :lua require('chatgpt').edit_with_instructions()<CR>
|
vnoremap <leader>Cf :CodeCompanion /fix<CR>
|
||||||
xnoremap <silent> <leader>Cd :ChatGPTRun docstring<CR>
|
vnoremap <leader>Cl :CodeCompanion /lsp<CR>
|
||||||
xnoremap <silent> <leader>Ct :ChatGPTRun add_tests<CR>
|
vnoremap <leader>CT :CodeCompanion /tests<CR>
|
||||||
xnoremap <silent> <leader>Co :ChatGPTRun optimize_code<CR>
|
|
||||||
xnoremap <silent> <leader>Cs :ChatGPTRun summarize<CR>
|
|
||||||
xnoremap <silent> <leader>Cf :ChatGPTRun fix_bugs<CR>
|
|
||||||
xnoremap <silent> <leader>Ce :ChatGPTRun explain_code<CR>
|
|
||||||
|
|
||||||
nnoremap <leader>db :lua require("dap").toggle_breakpoint()<CR>
|
nnoremap <leader>db :lua require("dap").toggle_breakpoint()<CR>
|
||||||
nnoremap <leader>dc :lua require("dap").continue()<CR>
|
nnoremap <leader>dc :lua require("dap").continue()<CR>
|
||||||
@ -157,7 +155,7 @@ nnoremap <leader>n :NvimTreeToggle<CR>
|
|||||||
|
|
||||||
|
|
||||||
nnoremap <leader>ob :Telescope file_browser<CR>
|
nnoremap <leader>ob :Telescope file_browser<CR>
|
||||||
nnoremap <leader>oc :ChatGPT<CR>
|
nnoremap <leader>oc :CodeCompanionChat<CR>
|
||||||
nnoremap <leader>oC :e ~/.config/nvim/init.vim<CR>
|
nnoremap <leader>oC :e ~/.config/nvim/init.vim<CR>
|
||||||
nnoremap <leader>oB :FloatermNew --title=btop --opener=vsplit btop<CR>
|
nnoremap <leader>oB :FloatermNew --title=btop --opener=vsplit btop<CR>
|
||||||
nnoremap <leader>od :FloatermNew --title=lazydocker --opener=vsplit lazydocker<CR>
|
nnoremap <leader>od :FloatermNew --title=lazydocker --opener=vsplit lazydocker<CR>
|
||||||
@ -184,6 +182,7 @@ nnoremap <silent> <leader>tp :FloatermToggle ipython<CR>
|
|||||||
nnoremap <silent> <leader>tP :FloatermToggle ipython-full<CR>
|
nnoremap <silent> <leader>tP :FloatermToggle ipython-full<CR>
|
||||||
nnoremap <silent> <leader>tt :FloatermToggle split-term<CR>
|
nnoremap <silent> <leader>tt :FloatermToggle split-term<CR>
|
||||||
nnoremap <silent> <leader>td :DBUIToggle<CR>
|
nnoremap <silent> <leader>td :DBUIToggle<CR>
|
||||||
|
nnoremap <silent> <leader>tc :CodeCompanionChat Toggle<CR>
|
||||||
nnoremap <silent> <leader>Tc :Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical<CR>
|
nnoremap <silent> <leader>Tc :Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical<CR>
|
||||||
nnoremap <silent> <leader>Tg :Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical<CR>
|
nnoremap <silent> <leader>Tg :Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical<CR>
|
||||||
nnoremap <silent> <leader>Tn :Telescope notify<CR>
|
nnoremap <silent> <leader>Tn :Telescope notify<CR>
|
||||||
|
71
lua/codecompanion/fidget-spinner.lua
Normal file
71
lua/codecompanion/fidget-spinner.lua
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
local progress = require("fidget.progress")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M:init()
|
||||||
|
local group = vim.api.nvim_create_augroup("CodeCompanionFidgetHooks", {})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "User" }, {
|
||||||
|
pattern = "CodeCompanionRequestStarted",
|
||||||
|
group = group,
|
||||||
|
callback = function(request)
|
||||||
|
local handle = M:create_progress_handle(request)
|
||||||
|
M:store_progress_handle(request.data.id, handle)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "User" }, {
|
||||||
|
pattern = "CodeCompanionRequestFinished",
|
||||||
|
group = group,
|
||||||
|
callback = function(request)
|
||||||
|
local handle = M:pop_progress_handle(request.data.id)
|
||||||
|
if handle then
|
||||||
|
M:report_exit_status(handle, request)
|
||||||
|
handle:finish()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
M.handles = {}
|
||||||
|
|
||||||
|
function M:store_progress_handle(id, handle)
|
||||||
|
M.handles[id] = handle
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:pop_progress_handle(id)
|
||||||
|
local handle = M.handles[id]
|
||||||
|
M.handles[id] = nil
|
||||||
|
return handle
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:create_progress_handle(request)
|
||||||
|
return progress.handle.create({
|
||||||
|
title = " Requesting assistance (" .. request.data.strategy .. ")",
|
||||||
|
message = "In progress...",
|
||||||
|
lsp_client = {
|
||||||
|
name = M:llm_role_title(request.data.adapter),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:llm_role_title(adapter)
|
||||||
|
local parts = {}
|
||||||
|
table.insert(parts, adapter.formatted_name)
|
||||||
|
if adapter.model and adapter.model ~= "" then
|
||||||
|
table.insert(parts, "(" .. adapter.model .. ")")
|
||||||
|
end
|
||||||
|
return table.concat(parts, " ")
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:report_exit_status(handle, request)
|
||||||
|
if request.data.status == "success" then
|
||||||
|
handle.message = "Completed"
|
||||||
|
elseif request.data.status == "error" then
|
||||||
|
handle.message = " Error"
|
||||||
|
else
|
||||||
|
handle.message = " Cancelled"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
170
lua/plugins.lua
170
lua/plugins.lua
@ -90,167 +90,19 @@ require('packer').startup(function(use)
|
|||||||
|
|
||||||
use { "zbirenbaum/copilot-cmp" }
|
use { "zbirenbaum/copilot-cmp" }
|
||||||
-- }}}
|
-- }}}
|
||||||
-- CHATGPT {{{
|
|
||||||
|
|
||||||
use({
|
use({
|
||||||
"jackMort/ChatGPT.nvim",
|
"olimorris/codecompanion.nvim",
|
||||||
commit = "24bcca7",
|
|
||||||
config = function()
|
|
||||||
require("chatgpt").setup({
|
|
||||||
api_key_cmd = "cat /home/sudacode/.openaikey",
|
|
||||||
yank_register = "+",
|
|
||||||
edit_with_instructions = {
|
|
||||||
diff = false,
|
|
||||||
keymaps = {
|
|
||||||
close = "<C-c>",
|
|
||||||
accept = "<C-y>",
|
|
||||||
toggle_diff = "<C-d>",
|
|
||||||
toggle_settings = "<C-o>",
|
|
||||||
toggle_help = "<C-h>",
|
|
||||||
cycle_windows = "<Tab>",
|
|
||||||
use_output_as_input = "<C-i>"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
chat = {
|
|
||||||
welcome_message = WELCOME_MESSAGE,
|
|
||||||
loading_text = "Loading, please wait ...",
|
|
||||||
question_sign = "", -- 🙂
|
|
||||||
answer_sign = "ﮧ", -- 🤖
|
|
||||||
border_left_sign = "",
|
|
||||||
border_right_sign = "",
|
|
||||||
max_line_length = 120,
|
|
||||||
sessions_window = {
|
|
||||||
active_sign = " ",
|
|
||||||
inactive_sign = " ",
|
|
||||||
current_line_sign = "",
|
|
||||||
border = {
|
|
||||||
style = "rounded",
|
|
||||||
text = { top = " Sessions " }
|
|
||||||
},
|
|
||||||
win_options = {
|
|
||||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
keymaps = {
|
|
||||||
close = "<C-c>",
|
|
||||||
yank_last = "<C-y>",
|
|
||||||
yank_last_code = "<C-k>",
|
|
||||||
scroll_up = "<C-u>",
|
|
||||||
scroll_down = "<C-d>",
|
|
||||||
new_session = "<C-n>",
|
|
||||||
cycle_windows = "<Tab>",
|
|
||||||
cycle_modes = "<C-f>",
|
|
||||||
next_message = "<C-j>",
|
|
||||||
prev_message = "<C-k>",
|
|
||||||
select_session = "<Space>",
|
|
||||||
rename_session = "r",
|
|
||||||
delete_session = "d",
|
|
||||||
draft_message = "<C-r>",
|
|
||||||
edit_message = "e",
|
|
||||||
delete_message = "d",
|
|
||||||
toggle_settings = "<C-o>",
|
|
||||||
toggle_sessions = "<C-p>",
|
|
||||||
toggle_help = "<C-h>",
|
|
||||||
toggle_message_role = "<C-r>",
|
|
||||||
toggle_system_role_open = "<C-s>",
|
|
||||||
stop_generating = "<C-x>"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
popup_layout = {
|
|
||||||
default = "center",
|
|
||||||
center = { width = "80%", height = "80%" },
|
|
||||||
right = { width = "30%", width_settings_open = "50%" }
|
|
||||||
},
|
|
||||||
popup_window = {
|
|
||||||
border = {
|
|
||||||
highlight = "FloatBorder",
|
|
||||||
style = "rounded",
|
|
||||||
text = { top = " ChatGPT " }
|
|
||||||
},
|
|
||||||
win_options = {
|
|
||||||
wrap = true,
|
|
||||||
linebreak = true,
|
|
||||||
foldcolumn = "1",
|
|
||||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder"
|
|
||||||
},
|
|
||||||
buf_options = { filetype = "markdown" }
|
|
||||||
},
|
|
||||||
system_window = {
|
|
||||||
border = {
|
|
||||||
highlight = "FloatBorder",
|
|
||||||
style = "rounded",
|
|
||||||
text = { top = " SYSTEM " }
|
|
||||||
},
|
|
||||||
win_options = {
|
|
||||||
wrap = true,
|
|
||||||
linebreak = true,
|
|
||||||
foldcolumn = "2",
|
|
||||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
popup_input = {
|
|
||||||
prompt = " ",
|
|
||||||
border = {
|
|
||||||
highlight = "FloatBorder",
|
|
||||||
style = "rounded",
|
|
||||||
text = { top_align = "center", top = " Prompt " }
|
|
||||||
},
|
|
||||||
win_options = {
|
|
||||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder"
|
|
||||||
},
|
|
||||||
submit = "<C-Enter>",
|
|
||||||
submit_n = "<Enter>",
|
|
||||||
max_visible_lines = 20
|
|
||||||
},
|
|
||||||
settings_window = {
|
|
||||||
setting_sign = " ",
|
|
||||||
border = { style = "rounded", text = { top = " Settings " } },
|
|
||||||
win_options = {
|
|
||||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
help_window = {
|
|
||||||
setting_sign = " ",
|
|
||||||
border = { style = "rounded", text = { top = " Help " } },
|
|
||||||
win_options = {
|
|
||||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
openai_params = {
|
|
||||||
model = "gpt-3.5-turbo",
|
|
||||||
frequency_penalty = 0,
|
|
||||||
presence_penalty = 0,
|
|
||||||
max_tokens = 300,
|
|
||||||
temperature = 0,
|
|
||||||
top_p = 1,
|
|
||||||
n = 1
|
|
||||||
},
|
|
||||||
openai_edit_params = {
|
|
||||||
model = "gpt-3.5-turbo",
|
|
||||||
frequency_penalty = 0,
|
|
||||||
presence_penalty = 0,
|
|
||||||
temperature = 0,
|
|
||||||
top_p = 1,
|
|
||||||
n = 1
|
|
||||||
},
|
|
||||||
use_openai_functions_for_edits = false,
|
|
||||||
actions_paths = {},
|
|
||||||
show_quickfixes_cmd = "Trouble quickfix",
|
|
||||||
predefined_chat_gpt_prompts =
|
|
||||||
"https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv",
|
|
||||||
highlights = {
|
|
||||||
help_key = "@symbol",
|
|
||||||
help_description = "@comment"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
requires = {
|
requires = {
|
||||||
"MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
"nvim-telescope/telescope.nvim"
|
"nvim-treesitter/nvim-treesitter",
|
||||||
}
|
"j-hui/fidget.nvim"
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
|
require("plugins.codecompanion.fidget-spinner"):init()
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- }}}
|
|
||||||
use({
|
use({
|
||||||
"iamcco/markdown-preview.nvim",
|
"iamcco/markdown-preview.nvim",
|
||||||
run = function() vim.fn["mkdp#util#install"]() end
|
run = function() vim.fn["mkdp#util#install"]() end
|
||||||
@ -290,9 +142,9 @@ require('packer').startup(function(use)
|
|||||||
|
|
||||||
-- DADBOD {{{
|
-- DADBOD {{{
|
||||||
|
|
||||||
use { 'tpope/vim-dadbod' }
|
-- use { 'tpope/vim-dadbod' }
|
||||||
use { 'kristijanhusak/vim-dadbod-ui' }
|
-- use { 'kristijanhusak/vim-dadbod-ui' }
|
||||||
use { 'kristijanhusak/vim-dadbod-completion' }
|
-- use { 'kristijanhusak/vim-dadbod-completion' }
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
15
plugin-confs/codecompanion.lua
Normal file
15
plugin-confs/codecompanion.lua
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
require("codecompanion").setup({
|
||||||
|
strategies = {
|
||||||
|
chat = {
|
||||||
|
adapter = "copilot",
|
||||||
|
},
|
||||||
|
inline = {
|
||||||
|
adapter = "copilot",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
display = {
|
||||||
|
action_palette = {
|
||||||
|
provider = "telescope"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -1,52 +1,103 @@
|
|||||||
require('lualine').setup {
|
local M = require("lualine.component"):extend()
|
||||||
options = {
|
|
||||||
icons_enabled = true,
|
M.processing = false
|
||||||
theme = 'codedark',
|
M.spinner_index = 1
|
||||||
-- theme = 'dracula',
|
|
||||||
-- theme = 'horizon',
|
local spinner_symbols = {
|
||||||
-- theme = 'onedark',
|
"⠋",
|
||||||
component_separators = { left = '', right = '' },
|
"⠙",
|
||||||
section_separators = { left = '', right = ''},
|
"⠹",
|
||||||
disabled_filetypes = {},
|
"⠸",
|
||||||
always_divide_middle = true,
|
"⠼",
|
||||||
},
|
"⠴",
|
||||||
sections = {
|
"⠦",
|
||||||
lualine_a = { 'mode' },
|
"⠧",
|
||||||
lualine_b = { 'branch', 'diff' },
|
"⠇",
|
||||||
lualine_c = { 'filename' },
|
"⠏",
|
||||||
lualine_x = {
|
|
||||||
{
|
|
||||||
'diagnostics',
|
|
||||||
'fileformat',
|
|
||||||
symbols = {
|
|
||||||
unix = '', -- e712
|
|
||||||
dos = '', -- e70f
|
|
||||||
mac = '', -- e711
|
|
||||||
}
|
|
||||||
}, 'encoding', 'fileformat', { 'filetype', colored = true, icon_only = false } },
|
|
||||||
lualine_y = { 'progress' },
|
|
||||||
lualine_z = { 'location' }
|
|
||||||
},
|
|
||||||
inactive_sections = {
|
|
||||||
lualine_a = {},
|
|
||||||
lualine_b = {},
|
|
||||||
lualine_c = {
|
|
||||||
{
|
|
||||||
'filename',
|
|
||||||
file_status = true, -- Displays file status (readonly status, modified status)
|
|
||||||
path = 0, -- 0: Just the filename
|
|
||||||
shorting_target = 40, -- Shortens path to leave 40 spaces in the window
|
|
||||||
symbols = {
|
|
||||||
modified = '[+]', -- Text to show when the file is modified.
|
|
||||||
readonly = '[-]', -- Text to show when the file is non-modifiable or readonly.
|
|
||||||
unnamed = '[No Name]', -- Text to show for unnamed buffers.
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
lualine_x = { 'location' },
|
|
||||||
lualine_y = {},
|
|
||||||
lualine_z = {}
|
|
||||||
},
|
|
||||||
tabline = {},
|
|
||||||
extensions = { 'quickfix', 'fzf', 'nvim-tree', 'symbols-outline', 'fugitive' }
|
|
||||||
}
|
}
|
||||||
|
local spinner_symbols_len = 10
|
||||||
|
|
||||||
|
-- Initializer
|
||||||
|
function M:init(options)
|
||||||
|
M.super.init(self, options)
|
||||||
|
|
||||||
|
local group = vim.api.nvim_create_augroup("CodeCompanionHooks", {})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "User" }, {
|
||||||
|
pattern = "CodeCompanionRequest*",
|
||||||
|
group = group,
|
||||||
|
callback = function(request)
|
||||||
|
if request.match == "CodeCompanionRequestStarted" then
|
||||||
|
self.processing = true
|
||||||
|
elseif request.match == "CodeCompanionRequestFinished" then
|
||||||
|
self.processing = false
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Function that runs every time statusline is updated
|
||||||
|
function M:update_status()
|
||||||
|
if self.processing then
|
||||||
|
self.spinner_index = (self.spinner_index % spinner_symbols_len) + 1
|
||||||
|
return spinner_symbols[self.spinner_index]
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
require('lualine').setup {
|
||||||
|
options = {
|
||||||
|
icons_enabled = true,
|
||||||
|
theme = 'codedark',
|
||||||
|
-- theme = 'dracula',
|
||||||
|
-- theme = 'horizon',
|
||||||
|
-- theme = 'onedark',
|
||||||
|
component_separators = { left = '', right = '' },
|
||||||
|
section_separators = { left = '', right = '' },
|
||||||
|
disabled_filetypes = {},
|
||||||
|
always_divide_middle = true,
|
||||||
|
},
|
||||||
|
sections = {
|
||||||
|
lualine_a = { 'mode' },
|
||||||
|
lualine_b = { 'branch', 'diff' },
|
||||||
|
lualine_c = { 'filename', M },
|
||||||
|
lualine_x = {
|
||||||
|
{
|
||||||
|
'diagnostics',
|
||||||
|
'fileformat',
|
||||||
|
symbols = {
|
||||||
|
unix = '', -- e712
|
||||||
|
dos = '', -- e70f
|
||||||
|
mac = '', -- e711
|
||||||
|
}
|
||||||
|
}, 'encoding', 'fileformat', { 'filetype', colored = true, icon_only = false } },
|
||||||
|
lualine_y = { 'progress' },
|
||||||
|
lualine_z = { 'location' }
|
||||||
|
},
|
||||||
|
inactive_sections = {
|
||||||
|
lualine_a = {},
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_c = {
|
||||||
|
{
|
||||||
|
'filename',
|
||||||
|
file_status = true, -- Displays file status (readonly status, modified status)
|
||||||
|
path = 0, -- 0: Just the filename
|
||||||
|
shorting_target = 40, -- Shortens path to leave 40 spaces in the window
|
||||||
|
symbols = {
|
||||||
|
modified = '[+]', -- Text to show when the file is modified.
|
||||||
|
readonly = '[-]', -- Text to show when the file is non-modifiable or readonly.
|
||||||
|
unnamed = '[No Name]', -- Text to show for unnamed buffers.
|
||||||
|
}
|
||||||
|
},
|
||||||
|
M
|
||||||
|
},
|
||||||
|
lualine_x = { 'location' },
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {}
|
||||||
|
},
|
||||||
|
tabline = {},
|
||||||
|
extensions = { 'quickfix', 'fzf', 'nvim-tree', 'symbols-outline', 'fugitive' }
|
||||||
|
}
|
||||||
|
|
||||||
|
-- return M
|
||||||
|
@ -157,7 +157,9 @@ cmp.setup({
|
|||||||
-- })
|
-- })
|
||||||
},
|
},
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = "copilot", group_index = 2 }, { name = "path", group_index = 2 },
|
{ name = "copilot", group_index = 2 },
|
||||||
|
{ name = "codecompanion", group_index = 2 },
|
||||||
|
{ name = "path", group_index = 2 },
|
||||||
{ name = 'nvim_lsp', group_index = 2 },
|
{ name = 'nvim_lsp', group_index = 2 },
|
||||||
{ name = 'nvim_lsp_signature_help', group_index = 2 },
|
{ name = 'nvim_lsp_signature_help', group_index = 2 },
|
||||||
{ name = 'nvim_lsp_document_symbol', group_index = 2 },
|
{ name = 'nvim_lsp_document_symbol', group_index = 2 },
|
||||||
@ -183,8 +185,11 @@ cmp.setup({
|
|||||||
priority_weight = 2,
|
priority_weight = 2,
|
||||||
comparators = {
|
comparators = {
|
||||||
require("copilot_cmp.comparators").prioritize,
|
require("copilot_cmp.comparators").prioritize,
|
||||||
|
cmp.config.compare.offset,
|
||||||
|
cmp.config.compare.exact,
|
||||||
require("copilot_cmp.comparators").score,
|
require("copilot_cmp.comparators").score,
|
||||||
require("copilot_cmp.comparators").recently_used,
|
require("copilot_cmp.comparators").recently_used,
|
||||||
|
cmp.config.compare.locality,
|
||||||
require("copilot_cmp.comparators").kind,
|
require("copilot_cmp.comparators").kind,
|
||||||
require("copilot_cmp.comparators").sort_text,
|
require("copilot_cmp.comparators").sort_text,
|
||||||
require("copilot_cmp.comparators").length,
|
require("copilot_cmp.comparators").length,
|
||||||
@ -223,37 +228,37 @@ for _, lsp in ipairs(servers) do
|
|||||||
lspconfig[lsp].setup {
|
lspconfig[lsp].setup {
|
||||||
on_attach = require("lsp-format").on_attach,
|
on_attach = require("lsp-format").on_attach,
|
||||||
on_init = function(client)
|
on_init = function(client)
|
||||||
if client.workspace_folders then
|
if client.workspace_folders then
|
||||||
local path = client.workspace_folders[1].name
|
local path = client.workspace_folders[1].name
|
||||||
if path ~= vim.fn.stdpath('config') and (vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc')) then
|
if path ~= vim.fn.stdpath('config') and (vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc')) then
|
||||||
return
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
|
||||||
runtime = {
|
runtime = {
|
||||||
-- Tell the language server which version of Lua you're using
|
-- Tell the language server which version of Lua you're using
|
||||||
-- (most likely LuaJIT in the case of Neovim)
|
-- (most likely LuaJIT in the case of Neovim)
|
||||||
version = 'LuaJIT'
|
version = 'LuaJIT'
|
||||||
},
|
},
|
||||||
-- Make the server aware of Neovim runtime files
|
-- Make the server aware of Neovim runtime files
|
||||||
workspace = {
|
workspace = {
|
||||||
checkThirdParty = false,
|
checkThirdParty = false,
|
||||||
library = {
|
library = {
|
||||||
vim.env.VIMRUNTIME
|
vim.env.VIMRUNTIME
|
||||||
-- Depending on the usage, you might want to add additional paths here.
|
-- Depending on the usage, you might want to add additional paths here.
|
||||||
-- "${3rd}/luv/library"
|
-- "${3rd}/luv/library"
|
||||||
-- "${3rd}/busted/library",
|
-- "${3rd}/busted/library",
|
||||||
}
|
}
|
||||||
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
|
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
|
||||||
-- library = vim.api.nvim_get_runtime_file("", true)
|
-- library = vim.api.nvim_get_runtime_file("", true)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
callSnippet = "Replace",
|
callSnippet = "Replace",
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {}
|
Lua = {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lspconfig[lsp].setup { on_attach = require("lsp-format").on_attach, capabilities = capabilities }
|
lspconfig[lsp].setup { on_attach = require("lsp-format").on_attach, capabilities = capabilities }
|
||||||
@ -263,4 +268,4 @@ end
|
|||||||
-- cmp.event:on("menu_opened",
|
-- cmp.event:on("menu_opened",
|
||||||
-- function() vim.b.copilot_suggestion_hidden = true end)
|
-- function() vim.b.copilot_suggestion_hidden = true end)
|
||||||
-- cmp.event:on("menu_closed",
|
-- cmp.event:on("menu_closed",
|
||||||
-- function() vim.b.copilot_suggestion_hidden = false end)
|
-- function() vim.b.copilot_suggestion_hidden = false end)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user