Merge branch 'master' of gitea.suda.codes:sudacode/nvim

This commit is contained in:
sudacode 2023-08-15 09:27:33 -07:00
commit 38d3e0e221
10 changed files with 155 additions and 103 deletions

View File

@ -37,10 +37,15 @@ 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/nvim-colorizer.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-ui.lua
" source ~/.config/nvim/plugin-confs/copilot.lua
" source ~/.config/nvim/plugin-confs/lsp-signature.lua
" source ~/.config/nvim/plugin-confs/nvim-docs-view.lua
" source ~/.config/nvim/plugin-confs/neodev.lua
" nvim and vim plugins
source ~/.vim/plugin-confs/floaterm.vim
source ~/.vim/plugin-confs/fzf.vim
@ -53,7 +58,7 @@ 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
" source ~/.config/nvim/lua/toggle_lsp_diagnostics.lua
" CUSTOM COMMANDS
command! -bang -nargs=? -complete=dir Files

View File

@ -59,6 +59,7 @@ nnoremap <leader>bp :bprev<CR>
nnoremap <leader>ca :lua vim.lsp.buf.code_action()<CR>
nnoremap <leader>cd :Telescope diagnostics<CR>
nnoremap <leader>cDt :lua require("dapui").toggle()<CR>
nnoremap <silent> <leader>cp :vert Copilot panel<CR>
nnoremap <silent> <leader>Ci :lua require('chatgpt').edit_with_instructions()<CR>
nnoremap <silent> <leader>Cd :ChatGPTRun docstring<CR>

View File

@ -71,14 +71,12 @@ require('packer').startup(function(use)
}
}
})
require("copilot.suggestion").toggle_auto_trigger()
end, 100)
end
}
use {
"zbirenbaum/copilot-cmp",
-- after = { "copilot.lua" },
config = function()
require("copilot_cmp").setup({
suggestion = { enabled = false },
@ -112,43 +110,6 @@ require('packer').startup(function(use)
use { 'junegunn/fzf', run = function() vim.fn['fzf#install']() end }
-- use {
-- "lewis6991/hover.nvim",
-- config = function()
-- require("hover").setup {
-- init = function()
-- -- Require providers
-- require("hover.providers.lsp")
-- -- require('hover.providers.gh')
-- -- require('hover.providers.jira')
-- require('hover.providers.man')
-- require('hover.providers.dictionary')
-- end,
-- preview_opts = {
-- border = "rounded"
-- -- border = {
-- -- { "╭", "FloatBorder" },
-- -- { "─", "FloatBorder" },
-- -- { "╮", "FloatBorder" },
-- -- { "│", "FloatBorder" },
-- -- { "╯", "FloatBorder" },
-- -- { "─", "FloatBorder" },
-- -- { "╰", "FloatBorder" },
-- -- { "│", "FloatBorder" },
-- -- }
-- },
-- -- Whether the contents of a currently open hover window should be moved
-- -- to a :h preview-window when pressing the hover keymap.
-- preview_window = false,
-- title = true
-- }
-- -- Setup keymaps
-- vim.keymap.set("n", "K", require("hover").hover, {desc = "hover.nvim"})
-- vim.keymap.set("n", "gK", require("hover").hover_select, {desc = "hover.nvim (select)"})
-- end
-- }
use 'norcalli/nvim-colorizer.lua'
use 'jiangmiao/auto-pairs'
use 'junegunn/fzf.vim'
@ -190,13 +151,29 @@ require('packer').startup(function(use)
end
}
use { 'jose-elias-alvarez/null-ls.nvim' }
use { 'ksyasuda/lsp_lines.nvim' }
use { 'https://git.sr.ht/~whynothugo/lsp_lines.nvim' }
use { 'neovim/nvim-lspconfig' }
use { 'onsails/lspkind-nvim' }
-- use 'ray-x/lsp_signature.nvim'
use { 'rmagatti/goto-preview' }
use 'saadparwaiz1/cmp_luasnip'
use 'williamboman/nvim-lsp-installer'
use({
"jackMort/ChatGPT.nvim",
commit = "24bcca7",
requires = {
"MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
}
})
use({
"iamcco/markdown-preview.nvim",
run = function() vim.fn["mkdp#util#install"]() end
})
use 'folke/neodev.nvim'
use 'mfussenegger/nvim-dap'
use { "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } }
use { 'Mofiqul/dracula.nvim' }
use({
@ -242,21 +219,5 @@ require('packer').startup(function(use)
use { 'olimorris/onedarkpro.nvim' }
use { 'projekt0n/github-nvim-theme' }
use({
"jackMort/ChatGPT.nvim",
commit = "24bcca7",
requires = {
"MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
}
})
use 'khaveesh/vim-fish-syntax'
use { "catppuccin/nvim", as = "catppuccin" }
use({
"iamcco/markdown-preview.nvim",
run = function() vim.fn["mkdp#util#install"]() end
})
end)

View File

@ -1,8 +1,12 @@
local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
vim.api.nvim_set_keymap('n', '<space>e',
'<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>',
opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>',
opts)
vim.api.nvim_set_keymap('n', '<space>q',
'<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
@ -60,20 +64,17 @@ vim.cmd [[autocmd! ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335
-- rounded
local border = {
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" }, { "", "FloatBorder" }, { "", "FloatBorder" },
{ "", "FloatBorder" }, { "", "FloatBorder" }, { "", "FloatBorder" },
{ "", "FloatBorder" }, { "", "FloatBorder" }
}
local handlers = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }),
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover,
{ border = border }),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers
.signature_help,
{ border = border })
}
-- local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
@ -93,7 +94,7 @@ local DEFAULT_SETTINGS = {
-- The list icon to use for servers that are pending installation.
server_pending = "",
-- The list icon to use for servers that are not installed.
server_uninstalled = "",
server_uninstalled = ""
},
keymaps = {
-- Keymap to expand a server in the UI
@ -105,8 +106,8 @@ local DEFAULT_SETTINGS = {
-- Keymap to update all installed servers
update_all_servers = "U",
-- Keymap to uninstall a server
uninstall_server = "X",
},
uninstall_server = "X"
}
},
-- The directory in which to install all servers.
@ -117,7 +118,7 @@ local DEFAULT_SETTINGS = {
-- and is not recommended.
--
-- Example: { "--proxy", "https://proxyserver" }
install_args = {},
install_args = {}
},
on_attach = on_attach,
handlers = handlers,
@ -128,7 +129,7 @@ local DEFAULT_SETTINGS = {
-- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further
-- servers that are requested to be installed will be put in a queue.
max_concurrent_installers = 4,
max_concurrent_installers = 4
}
vim.diagnostic.config({
@ -136,7 +137,7 @@ vim.diagnostic.config({
signs = true,
underline = false,
update_in_insert = false,
severity_sort = true,
severity_sort = true
})
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
@ -155,7 +156,9 @@ function PrintDiagnostics(opts, bufnr, line_nr, client_id)
local diagnostic_message = ""
for i, diagnostic in ipairs(line_diagnostics) do
diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "")
diagnostic_message = diagnostic_message ..
string.format("%d: %s", i,
diagnostic.message or "")
print(diagnostic_message)
if i ~= #line_diagnostics then
diagnostic_message = diagnostic_message .. "\n"
@ -166,24 +169,8 @@ end
-- vim.cmd [[ autocmd! CursorHold * lua PrintDiagnostics() ]]
local lsp_installer = require("nvim-lsp-installer")
-- Register a handler that will be called for each installed server when it's ready (i.e. when installation is finished
-- or if the server is already installed).
lsp_installer.on_server_ready(function(server)
local opts = {}
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function will take the provided server configuration and decorate it with the necessary properties
-- before passing it onwards to lspconfig.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(DEFAULT_SETTINGS)
end)
-- local servers = { 'jedi_language_server', 'bashls', 'vimls', 'yamlls', 'dockerls', 'rust_analyzer', 'clangd', 'ansiblels' }
-- for _, lsp in pairs(servers) do

View File

@ -1,5 +1,6 @@
require("lsp_lines").setup()
-- Disable virtual_text since it's redundant due to lsp_lines.
vim.diagnostic.config({
virtual_text = false,
})
vim.diagnostic.config({ virtual_text = false })
vim.keymap.set("", "<Leader>tl", require("lsp_lines").toggle,
{ desc = "Toggle lsp_lines" })

3
plugin-confs/neodev.lua Normal file
View File

@ -0,0 +1,3 @@
require("neodev").setup({
-- add any options here, or leave empty to use the default settings
})

View File

@ -217,10 +217,18 @@ local servers = {
'dotls', 'dockerls', 'html', 'cssls', 'lua_ls'
}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
-- on_attach = my_custom_on_attach,
capabilities = capabilities
}
if lsp == 'lua_ls' then
lspconfig[lsp].setup {
-- on_attach = my_custom_on_attach,
capabilities = capabilities,
callSnippet = "Replace"
}
else
lspconfig[lsp].setup {
-- on_attach = my_custom_on_attach,
capabilities = capabilities
}
end
end
cmp.event:on("menu_opened",

View File

@ -0,0 +1,31 @@
local dap = require('dap')
dap.adapters.bashdb = {
type = 'executable',
command = vim.fn.stdpath("data") ..
'/mason/packages/bash-debug-adapter/bash-debug-adapter',
name = 'bashdb'
}
dap.configurations.sh = {
{
type = 'bashdb',
request = 'launch',
name = "Launch file",
showDebugOutput = true,
pathBashdb = vim.fn.stdpath("data") ..
'/mason/packages/bash-debug-adapter/extension/bashdb_dir/bashdb',
pathBashdbLib = vim.fn.stdpath("data") ..
'/mason/packages/bash-debug-adapter/extension/bashdb_dir',
trace = true,
file = "${file}",
program = "${file}",
cwd = '${workspaceFolder}',
pathCat = "cat",
pathBash = "/bin/bash",
pathMkfifo = "mkfifo",
pathPkill = "pkill",
args = {},
env = {},
terminalKind = "integrated"
}
}

View File

@ -0,0 +1,48 @@
local dap = require('dap')
dap.adapters.python = function(cb, config)
if config.request == 'attach' then
---@diagnostic disable-next-line: undefined-field
local port = (config.connect or config).port
---@diagnostic disable-next-line: undefined-field
local host = (config.connect or config).host or '127.0.0.1'
cb({
type = 'server',
port = assert(port,
'`connect.port` is required for a python `attach` configuration'),
host = host,
options = { source_filetype = 'python' }
})
else
cb({
type = 'executable',
command = '/home/sudacode/Projects/Python/debugpy/env/bin/python',
args = { '-m', 'debugpy.adapter' },
options = { source_filetype = 'python' }
})
end
end
dap.configurations.python = {
{
-- The first three options are required by nvim-dap
type = 'python', -- the type here established the link to the adapter definition: `dap.adapters.python`
request = 'launch',
name = "Launch file",
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
program = "${file}", -- This configuration will launch the current file if used.
pythonPath = function()
-- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
-- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
-- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
local cwd = vim.fn.getcwd()
if vim.fn.executable(cwd .. '/env/bin/python') == 1 then
return cwd .. '/env/bin/python'
elseif vim.fn.executable(cwd .. '/.env/bin/python') == 1 then
return cwd .. '/.env/bin/python'
else
return '/usr/bin/python'
end
end
}
}

View File

@ -0,0 +1,7 @@
require("dapui").setup()
-- local dap, dapui = require("dap"), require("dapui")
-- dap.listeners.after.event_initialized["dapui_config"] =
-- function() dapui.open() end
-- dap.listeners.before.event_terminated["dapui_config"] =
-- function() dapui.close() end
-- dap.listeners.before.event_exited["dapui_config"] = function() dapui.close() end