1
0

Improvments to dap, lsp-cmp and trouble

- dap ui listeners
- LSPkind for symbols in suggestions'
- improving vim lua lsp support
- complete options added ( Preview )
- fixed annoying C-d not working ( had overwritten it for code actions)
- Added shortcut , s t to open a terminal at the bottom
- Added a keymap to exit terminal mode (thnx teejdev)
- set inccommand to split ( shows actions that will be taken in a split
window)
- fixed trouble suggestions toggle (C-t)
This commit is contained in:
Nigel Barink 2024-10-05 23:20:41 +02:00
parent 032d00a164
commit 52c7c5099d
Signed by: Nigel
GPG Key ID: 6893A31C2D84A9D2
6 changed files with 59 additions and 11 deletions

View File

@ -13,6 +13,7 @@
"gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" }, "gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" },
"harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },
"lazy.nvim": { "branch": "main", "commit": "460e1cd8f24e364d54543a4b0e83f6f4ec1f65fb" }, "lazy.nvim": { "branch": "main", "commit": "460e1cd8f24e364d54543a4b0e83f6f4ec1f65fb" },
"lspkind.nvim": { "branch": "master", "commit": "59c3f419af48a2ffb2320cea85e44e5a95f71664" },
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
"mason-lspconfig": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, "mason-lspconfig": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },

View File

@ -1,5 +1,4 @@
require("barink.vim") require("barink.vim")
require("barink.keys")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ vim.fn.system({
@ -12,5 +11,5 @@ if not vim.loop.fs_stat(lazypath) then
}) })
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("barink.keys")
require("lazy").setup("barink.plugins") require("lazy").setup("barink.plugins")

View File

@ -21,16 +21,27 @@ vim.keymap.set('i', '<A-j>', ':m .+1<CR>==gi', {noremap = true})
vim.keymap.set('i', '<A-k>', ':m .-2<CR>==gi', {noremap = true}) vim.keymap.set('i', '<A-k>', ':m .-2<CR>==gi', {noremap = true})
-- Diagnostics ! -- Diagnostics !
vim.keymap.set('n', '<C-T>', function() require('trouble').toggle() end ) vim.keymap.set('n', '<C-T>', function() require('trouble').toggle('diagnostics') end )
vim.keymap.set('n', '<leader>d', function () vim.diagnostic.open_float() end ) vim.keymap.set('n', '<leader>d', function () vim.diagnostic.open_float() end )
vim.keymap.set('n', '<leader>dn', function () vim.diagnostic.goto_next() end ) vim.keymap.set('n', '<leader>dn', function () vim.diagnostic.goto_next() end )
vim.keymap.set('n', '<leader>dp', function () vim.diagnostic.goto_prev() end ) vim.keymap.set('n', '<leader>dp', function () vim.diagnostic.goto_prev() end )
vim.keymap.set('n', '<C-d>', function () vim.lsp.buf.code_action() end) vim.keymap.set('n', '<leader>ca', function () vim.lsp.buf.code_action() end)
-- Debugging -- Debugging
vim.keymap.set('n', '<leader>sb', function () require('dap').toggle_breakpoint() end ) vim.keymap.set('n', '<leader>b', function () require('dap').toggle_breakpoint() end )
vim.keymap.set('n', '<leader>db', function () require('dapui').toggle() end )
vim.keymap.set('n', '<F5>', function () print("Start debug session" ) require('dap').continue() end ) vim.keymap.set('n', '<F5>', function () print("Start debug session" ) require('dap').continue() end )
vim.keymap.set('n', '<F6>', function () require('dap').step_over() end ) vim.keymap.set('n', '<F6>', function () require('dap').step_over() end )
vim.keymap.set('n', '<F7>', function () require('dap').step_into() end ) vim.keymap.set('n', '<F7>', function () require('dap').step_into() end )
vim.keymap.set('n', '<leader>=',":Gen Generate<CR>") vim.keymap.set('n', '<leader>=',":Gen Generate<CR>")
-- Easily hit escape in terminal mode.
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")
-- Open a terminal at the bottom of the screen with a fixed height.
vim.keymap.set("n", ",st", function()
vim.cmd.new()
vim.cmd.wincmd "J"
vim.api.nvim_win_set_height(0, 12)
vim.wo.winfixheight = true
vim.cmd.term()
end)

View File

@ -106,6 +106,20 @@ return {
args = {'dap', '-l', '127.0.0.1:${port}'}, args = {'dap', '-l', '127.0.0.1:${port}'},
} }
} }
local dap = require("dap")
local ui = require("dapui")
dap.listeners.before.attach.dapui_config = function()
ui.open()
end
dap.listeners.before.launch.dapui_config = function()
ui.open()
end
dap.listeners.before.event_terminated.dapui_config = function()
ui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
ui.close()
end
end end
} }
} }

View File

@ -19,8 +19,11 @@ return
version = "v2.*", version = "v2.*",
}, },
{'mfussenegger/nvim-jdtls', dependencies = {'nvim-dap'}}, {'mfussenegger/nvim-jdtls', dependencies = {'nvim-dap'}},
"onsails/lspkind.nvim",
}, },
config = function() config = function()
vim.opt.completeopt = { "menu", "menuone", "noselect", "preview"}
require("lspkind").init({})
require("mason").setup() require("mason").setup()
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({
ensure_installed = { "lua_ls", "bashls", "rust_analyzer" } ensure_installed = { "lua_ls", "bashls", "rust_analyzer" }
@ -32,7 +35,16 @@ return
enable_autosnippets = true, enable_autosnippets = true,
}) })
local cmp = require('cmp') local cmp = require('cmp')
local lspkind = require("lspkind")
cmp.setup({ cmp.setup({
formatting = {
format = lspkind.cmp_format({
mode = 'symbol',
maxwidth = 60,
ellipsis_char = '...',
show_labelDetails = true,
}),
},
snippet = { snippet = {
expand = function(args) expand = function(args)
require('luasnip').lsp_expand(args.body) require('luasnip').lsp_expand(args.body)
@ -132,10 +144,21 @@ return
gopls = true, gopls = true,
intelephense = true, intelephense = true,
lua_ls = { lua_ls = {
settings = { config = {
Lua = { settings = {
diagnostics = { Lua = {
globals = { 'vim'} runtime = {
version = 'LuaJIT',
},
workspace = {
checkThirdParty= false,
library = {
vim.env.VIMRUNTIME
}
},
-- diagnostics = {
-- globals = { 'vim'}
-- }
} }
} }
} }

View File

@ -25,7 +25,7 @@ vim.g.netrw_browse_split = 0
vim.g.netrw_winsize = 25 vim.g.netrw_winsize = 25
vim.opt.completeopt = {'menu', 'menuone', 'noselect' } vim.opt.completeopt = {'menu', 'menuone', 'noselect' }
vim.opt.inccommand = 'split'
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
callback = function (args) callback = function (args)
local client = vim.lsp.get_client_by_id(args.data.client_id) local client = vim.lsp.get_client_by_id(args.data.client_id)