all repos

dotfiles @ 116df19b6d7564f63dc245f1bf4b92e6d84d0f99

i use rach linux btw

dotfiles/config/nvim/after/ftplugin/go.lua (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
move nvim config in here, 1 month ago
1
vim.opt_local.expandtab = false
2
vim.opt_local.tabstop = 4
3
vim.opt_local.shiftwidth = 4
4
vim.opt_local.softtabstop = 4
5
6
Config.map("n", "<localleader>f", "<cmd>GoIfErr<cr>", true)
7
Config.map("n", "<localleader>c", "<cmd>GoCmt<cr>", true)
8
Config.map("n", "<localleader>t", "<cmd>GoTestAdd<cr>", true)
9
Config.map("n", "<localleader>a", "<cmd>GoTestsAll<cr>", true)
10
Config.map("n", "<localleader>e", "<cmd>GoTestsExp<cr>", true)
11
12
-- DLV
13
vim.fn.sign_define("Breakpoint", { text = "b", texthl = "Error" })
14
local dlv = { pane_id = nil, signs = {} }
15
local function get_dlv_pane_id()
16
  if dlv.pane_id then return dlv.pane_id end
17
  local res = vim
18
    .system(
19
      { "tmux", "list-panes", "-s", "-F", "#{pane_id}:#{pane_current_command}" },
20
      { text = true }
21
    )
22
    :wait()
23
  if res.code ~= 0 then
24
    vim.notify("Failed to list tmux panes", vim.log.levels.ERROR)
25
    return
26
  end
27
28
  for line in res.stdout:gmatch "[^\n]+" do
29
    local pane_id, command = line:match "([^:]+):(.*)"
30
    if command and command:match "^dlv" then
31
      dlv.pane_id = pane_id
32
      return pane_id
33
    end
34
  end
35
36
  vim.notify("No dlv session found", vim.log.levels.ERROR)
37
end
38
39
Config.map("n", "<localleader>B", function()
40
  for _, sid in ipairs(dlv.signs) do
41
    vim.fn.sign_unplace("Breakpoints", { id = sid })
42
  end
43
  dlv.signs = {}
44
  dlv.tab_id = nil
45
  vim.system { "tmux", "send-keys", "-t", get_dlv_pane_id(), "clearall", "Enter" }
46
  vim.notify("Cleared all breakpoints.", vim.log.levels.INFO)
47
end, true)
48
49
Config.map("n", "<localleader>b", function()
50
  local line = vim.fn.line "."
51
  local cmd = string.format("break %s:%d", vim.fn.expand "%:p", line)
52
  vim.system { "tmux", "send-keys", "-t", get_dlv_pane_id(), cmd, "Enter" }
53
54
  local fullpath = vim.fn.expand "%:p"
55
  local sid = tonumber(string.format("%d%04d", vim.fn.bufnr(), line)) --[[ @as number]]
56
  vim.fn.sign_place(sid, "Breakpoints", "Breakpoint", fullpath, { lnum = line })
57
  table.insert(dlv.signs, sid)
58
end, true)