updates
This commit is contained in:
parent
0626b3148b
commit
250a1d7388
26
init.vim
Normal file → Executable file
26
init.vim
Normal file → Executable file
@ -7,7 +7,7 @@ autocmd FileType help wincmd L
|
||||
autocmd FileType man wincmd L
|
||||
" make terminal not have line numbers
|
||||
autocmd TermOpen * setlocal nonumber norelativenumber
|
||||
|
||||
" call code actions function
|
||||
lua require('settings')
|
||||
lua require('plugins')
|
||||
source ~/.config/nvim/keybindings.vim
|
||||
@ -34,7 +34,7 @@ source ~/.config/nvim/plugin-confs/null-ls.lua
|
||||
source ~/.config/nvim/plugin-confs/nvim-cmp.lua
|
||||
source ~/.config/nvim/plugin-confs/fidget.lua
|
||||
" source ~/.config/nvim/plugin-confs/symbols-outline.lua
|
||||
source ~/.config/nvim/plugin-confs/chatgpt.lua
|
||||
" source ~/.config/nvim/plugin-confs/chatgpt.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-bash.lua
|
||||
@ -59,20 +59,18 @@ source ~/.config/nvim/plugin-confs/github-theme.lua
|
||||
source ~/.config/nvim/plugin-confs/onedarkpro.lua
|
||||
source ~/.config/nvim/plugin-confs/catppuccin.lua
|
||||
|
||||
" source ~/.config/nvim/lua/toggle_lsp_diagnostics.lua
|
||||
|
||||
" CUSTOM COMMANDS
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), <bang>0)
|
||||
" command! -bang -nargs=? -complete=dir Files
|
||||
" \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), <bang>0)
|
||||
|
||||
command! -bang -nargs=? -complete=dir AllFiles
|
||||
\ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({'dir': <q-args>, 'sink': 'e', 'source': 'rg --files --hidden --no-ignore', 'options': ['--layout=reverse', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), <bang>0))
|
||||
" command! -bang -nargs=? -complete=dir AllFiles
|
||||
" \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({'dir': <q-args>, 'sink': 'e', 'source': 'rg --files --hidden --no-ignore', 'options': ['--layout=reverse', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), <bang>0))
|
||||
|
||||
command! -bang -nargs=? -complete=dir Lines
|
||||
\ call fzf#vim#lines(<q-args>, ({'options': ['--layout=reverse']}), <bang>0)
|
||||
" command! -bang -nargs=? -complete=dir Lines
|
||||
" \ call fzf#vim#lines(<q-args>, ({'options': ['--layout=reverse']}), <bang>0)
|
||||
|
||||
command! -bang -nargs=? -complete=dir Buffers
|
||||
\ call fzf#vim#buffers(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), <bang>0)
|
||||
" command! -bang -nargs=? -complete=dir Buffers
|
||||
" \ call fzf#vim#buffers(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), <bang>0)
|
||||
|
||||
command! Reload execute "source ~/.config/nvim/init.vim"
|
||||
command! Config execute ":e ~/.config/nvim/init.vim"
|
||||
@ -89,3 +87,7 @@ command! PS execute ":PackerSync"
|
||||
" colorscheme catppuccin
|
||||
highlight Pmenu ctermfg=white ctermbg=black gui=NONE guifg=white guibg=#282C34
|
||||
highlight PmenuSel guifg=purple guibg=red
|
||||
|
||||
" run code actions on cursor hold if lsp is attached
|
||||
"autocmd CursorHold,CursorHoldI * lua require('code_action_utils').code_action_listener()
|
||||
autocmd CursorHold,CursorHoldI * lua if vim.tbl_isempty(vim.lsp.buf_get_clients()) then require('code_action_utils').code_action_listener() end
|
||||
|
@ -1,21 +1,29 @@
|
||||
|
||||
nmap <C-u> <C-u>zz
|
||||
nmap n nzzzv
|
||||
nmap N Nzzzv
|
||||
|
||||
" paste visually without yanking to clipboard
|
||||
xnoremap <leader>p "_dP
|
||||
|
||||
nnoremap <F4> :set paste!<Bar>set paste?<CR>
|
||||
nnoremap <F5> :set spell!<Bar>set spell?<CR>
|
||||
|
||||
" reselect visual selection after indent
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
||||
" move selected line(s) up or down and respect indent
|
||||
vnoremap J :m '>+1<CR>gv=gv
|
||||
vnoremap K :m '<-2<CR>gv=gv
|
||||
|
||||
" for toggling/hiding the split-term
|
||||
" search
|
||||
nnoremap // :Telescope current_buffer_fuzzy_find<CR>
|
||||
nnoremap ?? :Telescope lsp_document_symbols<CR>
|
||||
|
||||
" nnoremap Q !!$SHELL<CR>
|
||||
" nnoremap rn :lua vim.lsp.buf.rename()<CR>
|
||||
|
||||
nnoremap <C-J> :bnext<CR>
|
||||
nnoremap <C-K> :bprev<CR>
|
||||
|
||||
nnoremap <C-T> :wa<CR>:FloatermToggle floatterm<CR>
|
||||
tnoremap <C-T> <C-\><C-n>:FloatermToggle floatterm<CR>
|
||||
tnoremap <Esc> <C-\><C-n>
|
||||
tnoremap <leader>tt <C-\><C-N>:FloatermToggle split-term<CR>
|
||||
@ -23,13 +31,6 @@ tnoremap <leader>tf <C-\><C-N>:FloatermToggle floatterm<CR>
|
||||
tnoremap <leader>tp <C-\><C-N>:FloatermToggle ipython<CR>
|
||||
tnoremap <leader>tP <C-\><C-N>:FloatermToggle ipython-full<CR>
|
||||
|
||||
nnoremap <C-J> :bnext<CR>
|
||||
nnoremap <C-K> :bprev<CR>
|
||||
nnoremap <C-T> :wa<CR>:FloatermToggle floatterm<CR>
|
||||
|
||||
" open file under cursor, create if necessary
|
||||
nnoremap // :Telescope current_buffer_fuzzy_find<CR>
|
||||
nnoremap ?? :BLines<CR>
|
||||
|
||||
nnoremap gA :lua vim.lsp.buf.code_actions()<CR>
|
||||
nnoremap gd :Telescope lsp_definitions<CR>
|
||||
@ -44,17 +45,13 @@ nnoremap gl :lua vim.lsp.buf.code_lens()<CR>
|
||||
nnoremap gr :Telescope lsp_references<CR>
|
||||
nnoremap gs :lua vim.lsp.buf.signature_help()<CR>
|
||||
|
||||
nnoremap Q !!$SHELL<CR>
|
||||
|
||||
nnoremap rn :lua vim.lsp.buf.rename()<CR>
|
||||
|
||||
|
||||
nnoremap <leader>bb :Telescope buffers<CR>
|
||||
nnoremap <leader>bk :bdelete<CR>
|
||||
nnoremap <leader>bn :bnext<CR>
|
||||
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>cd :Telescope diagnostics<CR>
|
||||
nnoremap <leader>cDn :lua vim.diagnostic.goto_next()<CR>
|
||||
nnoremap <leader>cDp :lua vim.diagnostic.goto_prev()<CR>
|
||||
@ -66,14 +63,14 @@ nnoremap <silent> <leader>Ct :ChatGPTRun add_tests<CR>
|
||||
nnoremap <silent> <leader>Co :ChatGPTRun optimize_code<CR>
|
||||
nnoremap <silent> <leader>Cs :ChatGPTRun summarize<CR>
|
||||
nnoremap <silent> <leader>Cf :ChatGPTRun fix_bugs<CR>
|
||||
nnoremap <silent> <leader>Ce :ChatGPTRun explain<CR>
|
||||
nnoremap <silent> <leader>Ce :ChatGPTRun explain_code<CR>
|
||||
xnoremap <silent> <leader>Ci :lua require('chatgpt').edit_with_instructions()<CR>
|
||||
xnoremap <silent> <leader>Cd :ChatGPTRun docstring<CR>
|
||||
xnoremap <silent> <leader>Ct :ChatGPTRun add_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<CR>
|
||||
xnoremap <silent> <leader>Ce :ChatGPTRun explain_code<CR>
|
||||
|
||||
nnoremap <leader>db :lua require("dap").toggle_breakpoint()<CR>
|
||||
nnoremap <leader>dc :lua require("dap").continue()<CR>
|
||||
|
15
lua/code_action_utils.lua
Normal file
15
lua/code_action_utils.lua
Normal file
@ -0,0 +1,15 @@
|
||||
local M = {}
|
||||
|
||||
local lsp_util = vim.lsp.util
|
||||
|
||||
function M.code_action_listener()
|
||||
local context = { diagnostics = vim.lsp.diagnostic.get_line_diagnostics() }
|
||||
local params = lsp_util.make_range_params()
|
||||
params.context = context
|
||||
vim.lsp.buf_request(0, 'textDocument/codeAction', params,
|
||||
function(err, result, ctx, config)
|
||||
-- do something with result - e.g. check if empty and show some indication such as a sign
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
129
lua/plugins.lua
129
lua/plugins.lua
@ -25,6 +25,7 @@ require('packer').startup(function(use)
|
||||
|
||||
-- LSP/DEV {{{
|
||||
|
||||
-- COPILOT {{{
|
||||
use {
|
||||
"zbirenbaum/copilot.lua",
|
||||
event = "VimEnter",
|
||||
@ -85,9 +86,132 @@ require('packer').startup(function(use)
|
||||
}
|
||||
|
||||
use { "zbirenbaum/copilot-cmp" }
|
||||
-- }}}
|
||||
use({
|
||||
"jackMort/ChatGPT.nvim",
|
||||
commit = "24bcca7",
|
||||
config = function()
|
||||
require("chatgpt").setup({
|
||||
api_key_cmd = "cat /home/stickuser/.config/openai/apikey",
|
||||
yank_register = "+",
|
||||
edit_with_instructions = {
|
||||
diff = false,
|
||||
keymaps = {
|
||||
close = "<C-c>",
|
||||
accept = "<C-y>",
|
||||
toggle_diff = "<C-d>",
|
||||
toggle_settings = "<C-o>",
|
||||
cycle_windows = "<Tab>",
|
||||
use_output_as_input = "<C-i>"
|
||||
}
|
||||
},
|
||||
chat = {
|
||||
welcome_message = "HELLO FREUD",
|
||||
loading_text = "Loading, please wait ...",
|
||||
question_sign = "",
|
||||
answer_sign = "ﮧ",
|
||||
max_line_length = 120,
|
||||
sessions_window = {
|
||||
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>",
|
||||
select_session = "<Space>",
|
||||
rename_session = "r",
|
||||
delete_session = "d",
|
||||
draft_message = "<C-d>",
|
||||
toggle_settings = "<C-o>",
|
||||
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 = {
|
||||
border = { style = "rounded", text = { top = " Settings " } },
|
||||
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 = "code-davinci-edit-001",
|
||||
temperature = 0,
|
||||
top_p = 1,
|
||||
n = 1
|
||||
},
|
||||
actions_paths = {},
|
||||
show_quickfixes_cmd = "Trouble quickfix",
|
||||
predefined_chat_gpt_prompts =
|
||||
"https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv"
|
||||
})
|
||||
end,
|
||||
requires = {
|
||||
"MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim",
|
||||
"nvim-telescope/telescope.nvim"
|
||||
@ -113,6 +237,9 @@ require('packer').startup(function(use)
|
||||
use { 'onsails/lspkind-nvim' }
|
||||
use { 'jose-elias-alvarez/null-ls.nvim' }
|
||||
use 'folke/neodev.nvim'
|
||||
|
||||
-- DAP {{{
|
||||
|
||||
use 'mfussenegger/nvim-dap'
|
||||
use { "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } }
|
||||
use { 'mfussenegger/nvim-dap-python' }
|
||||
@ -120,6 +247,8 @@ require('packer').startup(function(use)
|
||||
|
||||
-- }}}
|
||||
|
||||
-- }}}
|
||||
|
||||
-- UI {{{
|
||||
|
||||
use {
|
||||
|
@ -1,112 +1 @@
|
||||
require("chatgpt").setup({
|
||||
api_key_cmd = "cat /home/sudacode/.config/openai/apikey",
|
||||
yank_register = "+",
|
||||
edit_with_instructions = {
|
||||
diff = false,
|
||||
keymaps = {
|
||||
close = "<C-c>",
|
||||
accept = "<C-y>",
|
||||
toggle_diff = "<C-d>",
|
||||
toggle_settings = "<C-o>",
|
||||
cycle_windows = "<Tab>",
|
||||
use_output_as_input = "<C-i>"
|
||||
}
|
||||
},
|
||||
chat = {
|
||||
welcome_message = WELCOME_MESSAGE,
|
||||
loading_text = "Loading, please wait ...",
|
||||
question_sign = "",
|
||||
answer_sign = "ﮧ",
|
||||
max_line_length = 120,
|
||||
sessions_window = {
|
||||
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>",
|
||||
select_session = "<Space>",
|
||||
rename_session = "r",
|
||||
delete_session = "d",
|
||||
draft_message = "<C-d>",
|
||||
toggle_settings = "<C-o>",
|
||||
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 = {
|
||||
border = { style = "rounded", text = { top = " Settings " } },
|
||||
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 = "code-davinci-edit-001",
|
||||
temperature = 0,
|
||||
top_p = 1,
|
||||
n = 1
|
||||
},
|
||||
actions_paths = {},
|
||||
show_quickfixes_cmd = "Trouble quickfix",
|
||||
predefined_chat_gpt_prompts = "https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv"
|
||||
})
|
||||
|
||||
|
@ -213,8 +213,8 @@ cmp.setup.cmdline(':', {
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
local servers = {
|
||||
'bashls', 'jedi_language_server', 'sqlls', 'jsonls', 'yamlls', 'vimls',
|
||||
'dotls', 'dockerls', 'html', 'cssls', 'lua_ls'
|
||||
'bashls', 'jedi_language_server', 'jsonls', 'yamlls', 'vimls', 'dotls',
|
||||
'dockerls', 'html', 'cssls', 'lua_ls'
|
||||
}
|
||||
for _, lsp in ipairs(servers) do
|
||||
if lsp == 'lua_ls' then
|
||||
|
Loading…
Reference in New Issue
Block a user