feat: added early nvim-dap configuration

still needs some work, it's a pretty weak configuration. It would also
be very cool if language-specific configurations were loaded with
ftplugin, rather than for each file.
This commit is contained in:
əlemi 2022-08-18 16:12:37 +02:00
parent a37ff7e71f
commit 51139ded5c
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 134 additions and 26 deletions

View file

@ -249,7 +249,7 @@ end
function PALETTE:set_telescope_colors()
-- FG BG ATTR
vim.api.nvim_set_hl(0, "TelescopeBorder", HIGHLIGHT(self.black.bright, nil, nil));
-- vim.api.nvim_set_hl(0, "TelescopePromptBorder", highlight(self.black.bright, nil, nil));
-- vim.api.nvim_set_hl(0, "TelescopePromptBorder", highlight(self.black.bright, nil, nil))
-- vim.api.nvim_set_hl(0, "TelescopePromptNormal", highlight());
-- vim.api.nvim_set_hl(0, "TelescopePromptPrefix", highlight());
-- vim.api.nvim_set_hl(0, "TelescopeNormal", highlight());
@ -260,6 +260,38 @@ function PALETTE:set_telescope_colors()
-- vim.api.nvim_set_hl(0, "TelescopePreviewLine", highlight());
end
function PALETTE:set_dap_colors()
-- FG BG ATTR
vim.api.nvim_set_hl(0, "DapMarks", HIGHLIGHT(self.purple.normal, nil, {bold=true}))
vim.api.nvim_set_hl(0, "DapStep", HIGHLIGHT(nil, self.black.normal, nil))
vim.api.nvim_set_hl(0, "DapStepNr", HIGHLIGHT(self.purple.normal, self.black.normal, {bold=true}))
-- DapUIVariable xxx links to Normal
-- DapUIScope xxx guifg=#00F1F5
-- DapUIType xxx guifg=#D484FF
-- DapUIValue xxx links to Normal
-- DapUIModifiedValue xxx gui=bold guifg=#00F1F5
-- DapUIDecoration xxx guifg=#00F1F5
-- DapUIThread xxx guifg=#A9FF68
-- DapUIStoppedThread xxx guifg=#00f1f5
-- DapUIFrameName xxx links to Normal
-- DapUISource xxx guifg=#D484FF
-- DapUILineNumber xxx guifg=#00f1f5
-- DapUIFloatBorder xxx guifg=#00F1F5
-- DapUIWatchesEmpty xxx guifg=#F70067
-- DapUIWatchesValue xxx guifg=#A9FF68
-- DapUIWatchesError xxx guifg=#F70067
-- DapUIBreakpointsPath xxx guifg=#00F1F5
-- DapUIBreakpointsInfo xxx guifg=#A9FF68
-- DapUIBreakpointsCurrentLine xxx gui=bold guifg=#A9FF68
-- DapUIBreakpointsLine xxx links to DapUILineNumber
-- DapUIBreakpointsDisabledLine xxx guifg=#424242
vim.fn.sign_define('DapBreakpoint', {text='', texthl='DapMarks', linehl='', numhl=''})
vim.fn.sign_define('DapBreakpointCondition', {text='', texthl='DapMarks', linehl='', numhl=''})
vim.fn.sign_define('DapBreakpointRejected', {text='', texthl='DapMarks', linehl='', numhl=''})
vim.fn.sign_define('DapLogPoint', {text='', texthl='DapMarks', linehl='', numhl=''})
vim.fn.sign_define('DapStopped', {text='', texthl='DapStepNr', linehl='DapStep', numhl='DapStepNr'})
end
--- set all theme highlight groups
function PALETTE:set_colors()
-- core
@ -273,6 +305,7 @@ function PALETTE:set_colors()
self:set_treesitter_colors()
self:set_gitsigns_colors()
self:set_telescope_colors()
self:set_dap_colors()
end
return PALETTE

View file

@ -28,12 +28,10 @@ local KEYBINDS = {
--|| GLOBAL KEYBINDS
function KEYBINDS:set_global_keys(opts)
-- Quick settings
vim.keymap.set('n', '<F10>', ':set hls!<CR>', opts)
vim.keymap.set('n', '<F9>', ':set wrap!<CR>', opts)
vim.keymap.set('n', '<F8>', ':set list!<CR>', opts)
vim.keymap.set('n', '<F7>', ':set spell!<CR>', opts)
vim.keymap.set('n', '<F6>', ':Hexmode<CR>', opts)
vim.keymap.set('n', '<F5>', ':Telescope oldfiles<CR>', opts)
vim.keymap.set('n', '<M-h>', ':set hls!<CR>', opts)
vim.keymap.set('n', '<M-w>', ':set wrap!<CR>', opts)
vim.keymap.set('n', '<M-l>', ':set list!<CR>', opts)
vim.keymap.set('n', '<M-s>', ':set spell!<CR>', opts)
-- Files navigation
vim.keymap.set('n', '<C-S-t>', ':tabnew<CR>', opts)
vim.keymap.set('n', '<M-t>', ':tabnew<CR>', opts) -- fallback for windows
@ -90,6 +88,7 @@ end
function KEYBINDS:set_telescope_keys(opts)
-- File navigation
vim.keymap.set('n', '<C-ESC>', ':Telescope oldfiles<CR>', opts)
vim.keymap.set('n', '<C-f>', ':Telescope find_files<CR>', opts)
vim.keymap.set('n', 'F', ':Telescope find_files<CR>', opts) -- fallback for windows
vim.keymap.set('n', '<C-,>', ':Telescope live_grep<CR>', opts)
@ -112,4 +111,16 @@ function KEYBINDS:set_telescope_keys(opts)
vim.keymap.set('n', '<C-PageDown>', ':Telescope diagnostics bufnr=0<CR>', opts)
end
function KEYBINDS:set_dap_keys(opts)
-- dapui
local dap = require('dap')
local dapui = require('dapui')
vim.keymap.set('n', '<F2>' , function() dapui.toggle({}) end, {})
vim.keymap.set('n', '<F3>' , function() dap.toggle_breakpoint() end, {})
vim.keymap.set('n', '<F5>' , function() dap.continue() end, {})
vim.keymap.set('n', '<F10>', function() dap.step_over() end, {})
vim.keymap.set('n', '<F11>', function() dap.step_into() end, {})
vim.keymap.set('n', '<F12>', function() dap.step_out() end, {})
end
return KEYBINDS

View file

@ -38,13 +38,68 @@ local init_fn = function(use)
use 'neovim/nvim-lspconfig' -- import LSP configurations
use 'simrat39/rust-tools.nvim' -- extra LSP defaults for rust
use 'hrsh7th/nvim-cmp' -- completion engine core
use 'hrsh7th/cmp-nvim-lsp' -- completions based on LSP
use 'hrsh7th/cmp-path' -- completions based on paths
use 'hrsh7th/cmp-buffer' -- completions based on buffer
use 'L3MON4D3/LuaSnip' -- snippet engine
use 'saadparwaiz1/cmp_luasnip' -- incorporate with completions
use {
'mfussenegger/nvim-dap', -- debugger adapter protocol
requires = {
'rcarriga/nvim-dap-ui', --batteries-included debugger ui
},
config = function()
local dap = require('dap')
dap.adapters.python = {
type = 'executable',
command = (vim.fn.environ()["VIRTUAL_ENV"] or "") .. "/bin/python",
args = { '-m', 'debugpy.adapter' },
}
dap.configurations.python = {
{
name = "Launch file",
type = "python",
request = "launch",
program = vim.fn.expand('%'),
cwd = '${workspaceFolder}',
},
}
dap.adapters.lldb = {
type = 'executable',
command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path
name = 'lldb'
}
dap.configurations.cpp = {
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
local program = ""
for i in string.gmatch(vim.fn.getcwd(), "([^/]+)") do
program = i
end
return vim.fn.getcwd() .. "/target/debug/" .. program -- TODO can I put startup file somewhere?
end,
cwd = '${workspaceFolder}',
},
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
require('keybinds'):set_dap_keys({})
require('dapui').setup()
end,
}
use {
'hrsh7th/nvim-cmp', -- completion engine core
requires = {
'hrsh7th/cmp-nvim-lsp', -- complete with LSP
'hrsh7th/cmp-nvim-lsp-signature-help', -- complete function signatures
'hrsh7th/cmp-nvim-lsp-document-symbol', -- complete document symbols
'hrsh7th/cmp-path', -- complete paths
'hrsh7th/cmp-buffer', -- complete based on buffer
'rcarriga/cmp-dap', -- complete in debugger
'saadparwaiz1/cmp_luasnip', -- complete with snippets
},
}
use {
'norcalli/nvim-colorizer.lua',
@ -61,7 +116,7 @@ local init_fn = function(use)
config = function()
require('telescope').load_extension('fzf')
require("telescope").load_extension("ui-select")
require('keybinds').set_telescope_keys({})
require('keybinds'):set_telescope_keys({})
end
}
@ -117,24 +172,33 @@ local init_fn = function(use)
-- TODO this part is messy, can I make it cleaner?
-- TODO can I put these setup steps inside their respective config callback?
-- TODO can I make them also load their highlight groups?
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args) require('luasnip').lsp_expand(args.body) end,
},
mapping = cmp.mapping.preset.insert({
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<C-Tab>'] = function(fallback) if cmp.visible() then cmp.select_next_item() else fallback() end end,
['<Tab>'] = cmp.mapping.confirm({ select = true }),
}),
mapping = cmp.mapping.preset.insert({ ['<Tab>'] = cmp.mapping.confirm({ select = true }) }),
sources = cmp.config.sources({
{ name = 'nvim_lsp_signature_help', max_item_count = 1 },
{ name = 'luasnip' },
{ name = 'nvim_lsp' },
}, {
{ name = 'path' },
}, {
{ name = 'buffer' },
{ name = 'path', max_item_count = 3 },
{ name = 'buffer', keyword_length = 3, max_item_count = 3 },
}),
})
cmp.setup.filetype({ "dap-repl", "dapui_watches" }, {
mapping = cmp.mapping.preset.insert({ ['<Tab>'] = cmp.mapping.confirm({ select = true }) }),
sources = {
{ name = 'dap' },
},
})
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'nvim_lsp_document_symbol' },
{ name = 'buffer', keyword_length = 3 },
})
})
@ -156,7 +220,8 @@ local init_fn = function(use)
server = {
capabilities = capabilities,
on_attach = set_lsp_binds,
}
},
dap = { adapter = require('dap').adapters.lldb },
})
rust_tools.inlay_hints.enable()
@ -191,4 +256,3 @@ end
return require('packer').startup(init_fn)