mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 16:41:43 +05:30
feat(nvim): Add golang support
This commit is contained in:
5
common/.config/nvim/lsp/gopls.lua
Normal file
5
common/.config/nvim/lsp/gopls.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
return {
|
||||
cmd = { "gopls", "--stdio" },
|
||||
filetypes = { "go" },
|
||||
settings = {},
|
||||
}
|
||||
@@ -12,6 +12,7 @@ vim.lsp.enable({
|
||||
"cssls",
|
||||
"docker_compose_language_service",
|
||||
"dockerls",
|
||||
"gopls",
|
||||
"html",
|
||||
"jsonls",
|
||||
"lua_ls",
|
||||
|
||||
@@ -1,165 +1,173 @@
|
||||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
dependencies = {
|
||||
"rcarriga/nvim-dap-ui",
|
||||
"nvim-neotest/nvim-nio",
|
||||
"mason-org/mason.nvim",
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
"<F5>",
|
||||
function()
|
||||
require("dap").continue()
|
||||
end,
|
||||
desc = "Debug: Start/Continue",
|
||||
},
|
||||
{
|
||||
"<leader>Ds",
|
||||
function()
|
||||
require("dap").continue()
|
||||
end,
|
||||
desc = "Debug: Start/Continue",
|
||||
},
|
||||
{
|
||||
"<F11>",
|
||||
function()
|
||||
require("dap").step_into()
|
||||
end,
|
||||
desc = "Debug: Step Into",
|
||||
},
|
||||
{
|
||||
"<leader>Di",
|
||||
function()
|
||||
require("dap").step_into()
|
||||
end,
|
||||
desc = "Debug: Step Into",
|
||||
},
|
||||
{
|
||||
"<F10>",
|
||||
function()
|
||||
require("dap").step_over()
|
||||
end,
|
||||
desc = "Debug: Step Over",
|
||||
},
|
||||
{
|
||||
"<leader>Do",
|
||||
function()
|
||||
require("dap").step_over()
|
||||
end,
|
||||
desc = "Debug: Step Over",
|
||||
},
|
||||
{
|
||||
"<S-F11>",
|
||||
function()
|
||||
require("dap").step_out()
|
||||
end,
|
||||
desc = "Debug: Step Out",
|
||||
},
|
||||
{
|
||||
"<leader>DO",
|
||||
function()
|
||||
require("dap").step_out()
|
||||
end,
|
||||
desc = "Debug: Step Out",
|
||||
},
|
||||
{
|
||||
"<F9>",
|
||||
function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end,
|
||||
desc = "Debug: Toggle Breakpoint",
|
||||
},
|
||||
{
|
||||
"<leader>Db",
|
||||
function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end,
|
||||
desc = "Debug: Toggle Breakpoint",
|
||||
},
|
||||
{
|
||||
"<leader>DB",
|
||||
function()
|
||||
require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
||||
end,
|
||||
desc = "Debug: Set Conditional Breakpoint",
|
||||
},
|
||||
{
|
||||
"<leader>Dt",
|
||||
function()
|
||||
require("dapui").toggle()
|
||||
end,
|
||||
desc = "Debug: Toggle UI",
|
||||
},
|
||||
{
|
||||
"<leader>Dl",
|
||||
function()
|
||||
require("dap").run_last()
|
||||
end,
|
||||
desc = "Debug: Run Last Configuration",
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
dependencies = {
|
||||
"rcarriga/nvim-dap-ui",
|
||||
"nvim-neotest/nvim-nio",
|
||||
"mason-org/mason.nvim",
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
|
||||
-- optional
|
||||
require("mason-nvim-dap").setup({
|
||||
automatic_installation = true,
|
||||
handlers = {},
|
||||
ensure_installed = {
|
||||
"codelldb",
|
||||
},
|
||||
})
|
||||
"leoluz/nvim-dap-go",
|
||||
},
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
|
||||
-- Dap UI setup
|
||||
dapui.setup({
|
||||
icons = { expanded = "▾", collapsed = "▸", current_frame = "*" },
|
||||
controls = {
|
||||
icons = {
|
||||
pause = "⏸",
|
||||
play = "▶",
|
||||
step_into = "⏎",
|
||||
step_over = "⏭",
|
||||
step_out = "⏮",
|
||||
step_back = "b",
|
||||
run_last = "▶▶",
|
||||
terminate = "⏹",
|
||||
disconnect = "⏏",
|
||||
require("dap-go").setup()
|
||||
|
||||
-- optional
|
||||
require("mason-nvim-dap").setup({
|
||||
automatic_installation = true,
|
||||
handlers = {},
|
||||
ensure_installed = {
|
||||
"codelldb",
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
-- Automatically open/close DAP UI
|
||||
dap.listeners.after.event_initialized["dapui_config"] = dapui.open
|
||||
dap.listeners.before.event_terminated["dapui_config"] = dapui.close
|
||||
dap.listeners.before.event_exited["dapui_config"] = dapui.close
|
||||
-- Dap UI setup
|
||||
dapui.setup({
|
||||
icons = { expanded = "▾", collapsed = "▸", current_frame = "*" },
|
||||
controls = {
|
||||
icons = {
|
||||
pause = "⏸",
|
||||
play = "▶",
|
||||
step_into = "⏎",
|
||||
step_over = "⏭",
|
||||
step_out = "⏮",
|
||||
step_back = "b",
|
||||
run_last = "▶▶",
|
||||
terminate = "⏹",
|
||||
disconnect = "⏏",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Setup virtual text to show variable values inline
|
||||
require("nvim-dap-virtual-text").setup()
|
||||
-- Automatically open/close DAP UI
|
||||
dap.listeners.before.attach["dapui_config"] = dapui.open
|
||||
dap.listeners.before.launch["dapui_config"] = dapui.open
|
||||
dap.listeners.before.event_terminated["dapui_config"] = dapui.close
|
||||
dap.listeners.before.event_exited["dapui_config"] = dapui.close
|
||||
dap.listeners.after.event_initialized["dapui_config"] = dapui.open
|
||||
|
||||
-- Setup Rust & React DAPs here
|
||||
dap.adapters.codelldb = {
|
||||
type = "server",
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = vim.fn.exepath("codelldb"),
|
||||
args = { "--port", "${port}" },
|
||||
},
|
||||
}
|
||||
-- Setup virtual text to show variable values inline
|
||||
require("nvim-dap-virtual-text").setup()
|
||||
|
||||
dap.configurations.rust = {
|
||||
-- Setup Rust & React DAPs here
|
||||
dap.adapters.codelldb = {
|
||||
type = "server",
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = vim.fn.exepath("codelldb"),
|
||||
args = { "--port", "${port}" },
|
||||
},
|
||||
}
|
||||
|
||||
dap.configurations.rust = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
},
|
||||
}
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
|
||||
"<F5>",
|
||||
function()
|
||||
require("dap").continue()
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
desc = "Debug: Start/Continue",
|
||||
},
|
||||
}
|
||||
end,
|
||||
{
|
||||
"<leader>Ds",
|
||||
function()
|
||||
require("dap").continue()
|
||||
end,
|
||||
desc = "Debug: Start/Continue",
|
||||
},
|
||||
{
|
||||
"<F11>",
|
||||
function()
|
||||
require("dap").step_into()
|
||||
end,
|
||||
desc = "Debug: Step Into",
|
||||
},
|
||||
{
|
||||
"<leader>Di",
|
||||
function()
|
||||
require("dap").step_into()
|
||||
end,
|
||||
desc = "Debug: Step Into",
|
||||
},
|
||||
{
|
||||
"<F10>",
|
||||
function()
|
||||
require("dap").step_over()
|
||||
end,
|
||||
desc = "Debug: Step Over",
|
||||
},
|
||||
{
|
||||
"<leader>Do",
|
||||
function()
|
||||
require("dap").step_over()
|
||||
end,
|
||||
desc = "Debug: Step Over",
|
||||
},
|
||||
{
|
||||
"<S-F11>",
|
||||
function()
|
||||
require("dap").step_out()
|
||||
end,
|
||||
desc = "Debug: Step Out",
|
||||
},
|
||||
{
|
||||
"<leader>DO",
|
||||
function()
|
||||
require("dap").step_out()
|
||||
end,
|
||||
desc = "Debug: Step Out",
|
||||
},
|
||||
{
|
||||
"<F9>",
|
||||
function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end,
|
||||
desc = "Debug: Toggle Breakpoint",
|
||||
},
|
||||
{
|
||||
"<leader>Db",
|
||||
function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end,
|
||||
desc = "Debug: Toggle Breakpoint",
|
||||
},
|
||||
{
|
||||
"<leader>DB",
|
||||
function()
|
||||
require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
||||
end,
|
||||
desc = "Debug: Set Conditional Breakpoint",
|
||||
},
|
||||
{
|
||||
"<leader>Dt",
|
||||
function()
|
||||
require("dapui").toggle()
|
||||
end,
|
||||
desc = "Debug: Toggle UI",
|
||||
},
|
||||
{
|
||||
"<leader>Dl",
|
||||
function()
|
||||
require("dap").run_last()
|
||||
end,
|
||||
desc = "Debug: Run Last Configuration",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -211,29 +211,27 @@ return {
|
||||
vim.defer_fn(function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
"regex",
|
||||
"bash",
|
||||
"css",
|
||||
"dockerfile",
|
||||
"go",
|
||||
"html",
|
||||
"javascript",
|
||||
"json5",
|
||||
"jsonc",
|
||||
"lua",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"lua",
|
||||
"rust",
|
||||
"typescript",
|
||||
"javascript",
|
||||
"bash",
|
||||
"html",
|
||||
"css",
|
||||
"json5",
|
||||
"yaml",
|
||||
"sql",
|
||||
"bash",
|
||||
"jsonc",
|
||||
"python",
|
||||
"dockerfile",
|
||||
"latex",
|
||||
"regex",
|
||||
"rust",
|
||||
"scss",
|
||||
"tsx",
|
||||
"vue",
|
||||
"sql",
|
||||
"svelte",
|
||||
"typst",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vue",
|
||||
"yaml",
|
||||
},
|
||||
|
||||
auto_install = true,
|
||||
|
||||
@@ -25,6 +25,7 @@ return {
|
||||
xml = { "xmllint" },
|
||||
yaml = { "yamlfmt" },
|
||||
|
||||
go = { "gofmt" },
|
||||
rust = { "rustfmt" },
|
||||
|
||||
["_"] = { "trim_whitespace" },
|
||||
|
||||
Reference in New Issue
Block a user