Nvim config update

This commit is contained in:
2024-10-20 18:22:16 +02:00
parent 36caf27d21
commit e20f8b6ea2
3 changed files with 148 additions and 10 deletions

View File

@@ -18,9 +18,6 @@ vim.opt.rtp:prepend(lazypath)
-- Add Plugins
require("lazy").setup({
-- Stats
{ 'wakatime/vim-wakatime', lazy = false },
-- Theme
{
"catppuccin/nvim",
@@ -31,11 +28,14 @@ require("lazy").setup({
end,
},
-- Syntax highlighting support
-- "fladson/vim-kitty",
-- Stats
{ 'wakatime/vim-wakatime', lazy = false },
-- Highlight
{ "RRethy/vim-illuminate" },
-- Comment visual regions/lines
"numToStr/Comment.nvim",
{ "numToStr/Comment.nvim", opts = {} },
-- Autoclose brackets
{ "m4xshen/autoclose.nvim", opts = {} },
@@ -64,6 +64,17 @@ require("lazy").setup({
},
},
-- Debug
{
"rcarriga/nvim-dap-ui",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio"
},
opts = {}
},
{ "theHamsta/nvim-dap-virtual-text", opts = {} },
-- LSP
{
"neovim/nvim-lspconfig",
@@ -73,7 +84,6 @@ require("lazy").setup({
"williamboman/mason-lspconfig.nvim",
-- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ "j-hui/fidget.nvim", tag = "legacy", opts = {} },
-- Additional lua configuration, makes nvim stuff amazing!
@@ -94,8 +104,12 @@ require("lazy").setup({
-- Adds a number of user-friendly snippets
'rafamadriz/friendly-snippets',
-- Ai cmp
'tzachar/cmp-ai'
},
},
{ 'tzachar/cmp-ai', dependencies = 'nvim-lua/plenary.nvim' },
-- Show available command
{
@@ -238,6 +252,72 @@ vim.keymap.set("n", "<C-j>", "<C-W>j")
vim.keymap.set("n", "<C-k>", "<C-W>k")
vim.keymap.set("n", "<C-l>", "<C-W>l")
--- Debug
local dap, dapui, dapvs = require("dap"), require("dapui"), require('dap.ext.vscode')
vim.keymap.set("n", "<Leader>b", dap.toggle_breakpoint, { desc = "[b] Debug toggle breakpoint" })
vim.keymap.set("n", "<Leader>dc", dap.continue, { desc = "[c] Debug Continue/Start" })
vim.keymap.set("n", "<Leader>n", dap.step_over, { desc = "[n] Debug step over" })
vim.keymap.set("n", "<Leader>N", dap.step_into, { desc = "[N] Debug step into" })
vim.keymap.set("n", "<Leader>m", dap.step_out, { desc = "[m] Debug step out" })
vim.keymap.set("n", "<Leader>dt", dapui.toggle, { desc = "[t] Debug toggle view" })
vim.keymap.set("n", "<Leader>dl", function()
dapvs.load_launchjs("launch.json", { cppdbg = { 'c', 'cpp' } })
end,
{ desc = "[l] Debug load launch config" })
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.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
dap.adapters.cppdbg = {
id = "cppdbg",
type = "executable",
command = "/home/pa/dap/c/extension/debugAdapters/bin/OpenDebugAD7",
}
dap.configurations.c = {
{
name = "Launch file",
type = "cppdbg",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
args = function()
local s = vim.fn.input('Args: ')
local t = {}
for word in s:gmatch("%S+") do
table.insert(t, word)
end
return t
end,
cwd = '${workspaceFolder}',
stopAtEntry = true,
},
-- {
-- name = 'Attach to gdbserver :1234',
-- type = 'cppdbg',
-- request = 'launch',
-- MIMode = 'gdb',
-- miDebuggerServerAddress = 'localhost:1234',
-- miDebuggerPath = '/usr/bin/gdb',
-- cwd = '${workspaceFolder}',
-- program = function()
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
-- end,
-- },
}
--- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
@@ -377,8 +457,8 @@ local on_attach = function(_, bufnr)
nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
nmap("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
nmap("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
nmap("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
nmap("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
-- See `:help K` for why this keymap
@@ -389,6 +469,7 @@ local on_attach = function(_, bufnr)
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
nmap("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder")
nmap("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
nmap("<leader>f", vim.lsp.buf.format, "[F]ormat")
nmap("<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, "[W]orkspace [L]ist Folders")
@@ -425,12 +506,22 @@ local servers = {
jsonls = {},
clangd = {},
cssls = {},
jdtls = {},
jdtls = {
java = {
maven = { downloadSources = true }
}
},
html = {},
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
workspace = {
library = vim.api.nvim_get_runtime_file('', true),
checkThirdParty = false
},
telemetry = { enable = false },
diagnostics = {
globals = { "vim" }
}
},
},
}
@@ -505,8 +596,39 @@ cmp.setup {
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
-- { name = "cmp_ai" },
},
}
-- local cmp_ai = require('cmp_ai.config')
-- cmp_ai:setup({
-- max_lines = 100,
-- provider = 'Ollama',
-- provider_options = {
-- model = 'mistral',
-- },
-- notify = true,
-- notify_callback = function(msg)
-- vim.notify(msg)
-- end,
-- run_on_every_keystroke = true,
-- ignored_file_types = {
-- -- default is not to ignore
-- -- uncomment to ignore in lua:
-- -- lua = true
-- },
-- })
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
-- notify_callback = function(msg)
-- vim.notify(msg)
-- end,
-- run_on_every_keystroke = true,
-- ignored_file_types = {
-- -- default is not to ignore
-- -- uncomment to ignore in lua:
-- -- lua = true
-- },
-- })
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et