update nvim config
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This commit is contained in:
parent
e345f703fe
commit
fc3aafc2d1
1
init.lua
1
init.lua
|
|
@ -1078,6 +1078,7 @@ require('lazy').setup({
|
||||||
},
|
},
|
||||||
{ -- Highlight, edit, and navigate code
|
{ -- Highlight, edit, and navigate code
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
branch = 'master',
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,7 @@ return {
|
||||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
group = augroup,
|
group = augroup,
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function() vim.lsp.buf.format { async = false } end,
|
||||||
vim.lsp.buf.format { async = false }
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,23 @@ return {
|
||||||
request = 'launch',
|
request = 'launch',
|
||||||
program = function()
|
program = function()
|
||||||
local cwd = vim.fn.getcwd()
|
local cwd = vim.fn.getcwd()
|
||||||
local default_binary = cwd .. '/target/debug/' .. vim.fn.fnamemodify(cwd, ':t')
|
local cargo_toml = cwd .. '/Cargo.toml'
|
||||||
|
|
||||||
|
local binary_name = vim.fn.fnamemodify(cwd, ':t') -- Fallback to folder name
|
||||||
|
|
||||||
|
-- Read Cargo.toml to find the actual package name
|
||||||
|
if vim.fn.filereadable(cargo_toml) == 1 then
|
||||||
|
for _, line in ipairs(vim.fn.readfile(cargo_toml)) do
|
||||||
|
-- Look for name = "package_name" under the [package] table
|
||||||
|
local name = string.match(line, '^%s*name%s*=%s*["\']([^"\']+)["\']')
|
||||||
|
if name then
|
||||||
|
binary_name = name
|
||||||
|
break -- Stop reading once we find the name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local default_binary = cwd .. '/target/debug/' .. binary_name
|
||||||
return vim.fn.input('Path to executable: ', default_binary, 'file')
|
return vim.fn.input('Path to executable: ', default_binary, 'file')
|
||||||
end,
|
end,
|
||||||
cwd = '${workspaceFolder}',
|
cwd = '${workspaceFolder}',
|
||||||
|
|
@ -179,8 +195,12 @@ return {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Override default configurations with `launch.json`
|
local vscode = require 'dap.ext.vscode'
|
||||||
require('dap.ext.vscode').load_launchjs('.nvim/launch.json', { lldb = { 'c', 'cpp', 'rust' } })
|
|
||||||
|
-- 1. Define the adapter-to-filetype mappings
|
||||||
|
vscode.type_to_filetypes = {
|
||||||
|
lldb = { 'c', 'cpp', 'rust' },
|
||||||
|
}
|
||||||
|
|
||||||
vim.keymap.set('n', '<space>b', dap.toggle_breakpoint)
|
vim.keymap.set('n', '<space>b', dap.toggle_breakpoint)
|
||||||
vim.keymap.set('n', '<space>gb', dap.run_to_cursor)
|
vim.keymap.set('n', '<space>gb', dap.run_to_cursor)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue