stable nvim with lsp for go

main
spike 2 years ago
parent 8994636c3f
commit 329f12a5e3

@ -1,3 +1,7 @@
- use libmodal + whichkey ?
- gisigns: add navigation between hunks (vs fugitive ?)
- optimize git flow
- navigator icons update
- vim-bookmarks disable default keymaps and use manaul ones (keep ma ...)
- Setup telescope/fzf mappings together
- LSP C-i is tab does not allow to jump back into history

@ -1,3 +1,3 @@
augroup sp4ke_json
augroup my_json
au FileType json set formatprg=jq
aug END

@ -0,0 +1,2 @@
set makeprg=cargo\ run
nnoremap <Space>c :AsyncRun cargo check<CR>

@ -67,7 +67,7 @@ M.general = { --{{{
["<C-s>"] = { "<cmd> update <CR>", "save file" },
-- Copy all
["<C-c>"] = { "<cmd> %y+ <CR>", "copy whole file" },
["<leader>Y"] = { "<cmd> %y+ <CR>", "copy whole file" },
-- line numbers
["<leader>n"] = { "<cmd> set nu!<CR><cmd> set rnu!<CR>", "toggle line number" },
@ -121,7 +121,7 @@ M.general = { --{{{
["k"] = { "gk" },
-- new buffer
["<S-b>"] = { "<cmd> enew <CR>", "new buffer" },
["<leader>bb"] = { "<cmd> enew <CR>", "new buffer" },
-- new tab
["<leader><Tab>"] = { "<cmd> tabe <CR>", "new tab" },
@ -204,7 +204,8 @@ M.general = { --{{{
packer.snapshot(snapname)
end
, "packer snapshot"},
["<leader>ps"] = { "<cmd> PackerStatus<CR>", "packer status"},
["<leader>pst"] = { "<cmd> PackerStatus<CR>", "packer status"},
["<leader>psc"] = { "<cmd> PackerSync<CR>", "packer sync"},
["<leader>pr"] = { function()
@ -490,6 +491,41 @@ M.lspconfig = { --{{{
},
} --}}}
M.dap = {
plugin = true,
n = {
["<leader>ds"] = {
function()
if vim.o.filetype == "go" then
local spdap = require("sp4ke.dap")
spdap.setup()
spdap.go_debug()
end
end,
"start dap session"},
["<leader>dS"] = {
function()
if vim.o.filetype == "go" then
vim.cmd("GoDbgStop")
end
end,
"stop dap session"
},
["<leader>dd"] = {"<cmd> DapToggleBreakpoint <CR>"},
["<leader>dc"] = {function()
vim.ui.input({ prompt = "condition> "}, function(input)
require("dap").set_breakpoint(input)
end)
end, "dap conditional breakpoint"},
["<leader>dm"] = {function()
require("sp4ke.dapmode").start()
end, "enter dap mode"}
},
}
M.nvimtree = { --{{{
plugin = true,
@ -704,7 +740,7 @@ M.asyncrun = { --{{{
M.vim_bookmarks = {--{{{
n = {
["m "] = {"<cmd> Telescope vim_bookmarks<CR>", "show bookmarks"},
["<space>m"] = {"<cmd> Telescope vim_bookmarks<CR>", "show bookmarks"},
["mm"] = {"<cmd> BookmarkToggle<CR>", "toggle bookmarks"},
["<leader>mm"] = {"<cmd> BookmarkAnnotate<CR>", "annotation bookmarks"},
["<leader>mc"] = {"<cmd> BookmarkClear<CR>", "clear bookmarks in buffer"},

@ -27,10 +27,14 @@ M.ui = {
italic = true,
},
St_LspInfo = {
fg = "teal"
fg = "white"
},
},
hl_add = {
Visual = {
bg = "yellow",
fg = "black",
},
BookmarkSign = {
fg = "blue",
},
@ -42,13 +46,17 @@ M.ui = {
bg = "yellow"
},
DiagnosticInfo = { -- nvchad uses DiagnosticInformation wrong hi group for lsp
fg = "teal",
fg = "white",
italic = true,
},
DiagnosticFloatingInfo = {
fg="white",
italic=true,
},
DiagnosticUnderlineError = {
fg="black",
bg="pink",
},
-- Code Lens related colors
LspCodeLens = {
fg = "vibrant_green",
@ -61,7 +69,19 @@ M.ui = {
-- end of code lens colors
DiffText = {
bg = "vigrant_green"
}
},
St_DapMode = {
fg = "black2",
bg = "baby_pink",
},
St_DapModeSep = {
fg = "baby_pink",
bg = "one_bg3",
},
St_DapModeSep2 = {
fg = "grey",
bg = "baby_pink",
},
},
-- hl_override = {
-- CursorLine = {

@ -7,7 +7,7 @@ end
M = {}
local config = {
debug = true,
debug = false,
transparency = 5,
lsp_signature_help = false, -- needs plugin lsp_signature
default_mapping = true,
@ -20,7 +20,7 @@ local config = {
func = vim.lsp.buf.signature_help,
desc = 'lsp signature_help'
},
{ key = '<C-i>', func = vim.lsp.buf.signature_help, desc = 'lsp signature_help' },
-- { key = '<C-i>', func = vim.lsp.buf.signature_help, desc = 'lsp signature_help' },
{ key = 'g0', func = require('navigator.symbols').document_symbols, desc = 'lsp document_symbols' },
{ key = 'gW', func = require('navigator.workspace').workspace_symbol_live, desc = 'lsp workspace_symbol_live' },
{ key = '<c-]>', func = require('navigator.definition').definition, desc = 'lsp definition' },
@ -124,9 +124,10 @@ local config = {
treesitter_defult = '🌲',
doc_symbols = '',
},
mason = true,
mason_disabled_for = {"ccls"}, -- disable mason for specified lspclients
lsp = {
document_highlight = false,
mason = true,
format_on_save = false, -- applies to all formatting feature of neovim
-- including auto-fold
diagnostic = {
@ -162,7 +163,7 @@ local config = {
["lua-dev"] = {
library = {
enabled = true,
plugins = {"navigator.lua", "guihua.lua"},
plugins = {"navigator.lua", "guihua.lua", "go.nvim"},
runtime = true,
types = true,
}

@ -0,0 +1,17 @@
local present, todo = pcall(require, "todo-comments")
if not present then
return
end
M = {}
local config = {
}
M.setup = function()
todo.setup(config)
end
return M

@ -0,0 +1,19 @@
local ok, tscontext = pcall(require,"treesitter-context")
if not ok then return end
local M = {}
local config = {
enable = true
}
M.config = config
function M.setup()
tscontext.setup(config)
end
return M

@ -1,5 +1,7 @@
return {
ensure_installed = {
"query",
"css",
"lua",
"go",
"rust",
@ -7,6 +9,7 @@ return {
"bash",
"python",
"c",
"cpp",
"haskell",
"javascript",
"html",
@ -97,5 +100,9 @@ return {
["~"] = "@parameter.inner"
},
}
},
playground = {
enable = true,
}
}

@ -36,6 +36,7 @@ return {
require("core.lazy_load").on_file_open "nvim-treesitter"
require("core.lazy_load").on_file_open "nvim-treesitter-textobjects"
require("core.lazy_load").on_file_open "nvim-treesitter-textsubjects"
require("core.lazy_load").on_file_open "nvim-treesitter-context"
-- require("core.lazy_load").on_file_open "nvim-ts-rainbow"
end
},
@ -45,6 +46,25 @@ return {
["RRethy/nvim-treesitter-textsubjects"] = {
opt = true,
},
-- Treesitter dev/exploration tool
["nvim-treesitter/playground"] = {
opt = true,
},
["nvim-treesitter/nvim-treesitter-context"] = {
opt = true,
config = function()
require("custom.plugins.configs.treesitter-context").setup()
end
},
["folke/todo-comments.nvim"] = {
after = "nvim-treesitter",
config = function()
require("custom.plugins.configs.todo-comments").setup()
end
},
-- ["p00f/nvim-ts-rainbow"] = {
-- opt = true,
-- },
@ -53,7 +73,8 @@ return {
local disabled_ft = {
"guihua",
"clap_input",
"guihua_rust,"
"guihua_rust,",
"TelescopePrompt"
}
require("cmp").setup.buffer {
@ -69,15 +90,15 @@ return {
["mfussenegger/nvim-dap"] = {
lock = true,
module = "dap"
module = "dap",
setup = function()
require("core.utils").load_mappings "dap"
end,
},
["rcarriga/nvim-dap-ui"] = {
lock = true,
after = "nvim-dap",
config = function ()
require('dapui').setup()
end
},
["theHamsta/nvim-dap-virtual-text"] = {
@ -131,7 +152,7 @@ return {
["skywind3000/asyncrun.vim"] = {
lock = true,
cmd = "AsyncRun",
config = function()
setup = function()
require("core.utils").load_mappings "asyncrun"
vim.g.asyncrun_open = 8
end
@ -189,6 +210,11 @@ return {
end
},
-- create new vim modes
["Iron-E/nvim-libmodal"] = {
lock = true,
},
-- ["chentoast/marks.nvim"] = {
-- opt = true,
-- keys = {"m", "d"},
@ -241,8 +267,8 @@ return {
["williamboman/mason-lspconfig.nvim"] = {
lock = true,
requires = {"williamboman/mason.nvim", "nvim-lspconfig"},
after = "mason.nvim",
module = "mson-lspconfig.nvim",
-- after = "mason.nvim",
module = {"mson-lspconfig.nvim", "mason.nvim"},
config = function()
require("mason-lspconfig").setup({})
end,
@ -250,16 +276,26 @@ return {
["ray-x/guihua.lua"] = {
lock = true,
module = {"navigator"},
run= "cd lua/fzy && make"
run = "cd lua/fzy && make",
config = function()
require("guihua.maps").setup {
maps = {
close_view = "<C-x>",
}
}
end
},
-- ["https://git.sp4ke.xyz/sp4ke/navigator.lua"] =
--
["ray-x/navigator.lua"] = {
lock = true,
opt = true,
after = { "nvim-lspconfig", "base46", "ui" },
module = "navigator.lua",
after = { "nvim-lspconfig", "base46", "ui", "mason.nvim", "mason-lspconfig.nvim" },
requires = {"neovim/nvim-lspconfig", "ray-x/guihua.lua", "nvim-treesitter/nvim-treesitter"},
setup = function()
require("core.lazy_load").on_file_open "navigator.lua"
require("core.utils").load_mappings "navigator"
end,
config = function()
@ -350,6 +386,8 @@ return {
-- lsp_diag_signs = false,
lsp_codelens = false, -- use navigator
textobjects = true,
dap_debug_keymap = false,
})
end
}

@ -1,3 +1,5 @@
-- called in chadrc
--
local fn = vim.fn
local sep_style = vim.g.statusline_sep_style
local separators = (type(sep_style) == "table" and sep_style)
@ -5,9 +7,56 @@ local separators = (type(sep_style) == "table" and sep_style)
local sep_r = separators["right"]
local myicons = require("custom.chadrc").ui.myicons
-- called in chadrc
--
local modes = {
["n"] = { "NORMAL", "St_NormalMode" },
["niI"] = { "NORMAL i", "St_NormalMode" },
["niR"] = { "NORMAL r", "St_NormalMode" },
["niV"] = { "NORMAL v", "St_NormalMode" },
["no"] = { "N-PENDING", "St_NormalMode" },
["i"] = { "INSERT", "St_InsertMode" },
["ic"] = { "INSERT (completion)", "St_InsertMode" },
["ix"] = { "INSERT completion", "St_InsertMode" },
["t"] = { "TERMINAL", "St_TerminalMode" },
["nt"] = { "NTERMINAL", "St_NTerminalMode" },
["v"] = { "VISUAL", "St_VisualMode" },
["V"] = { "V-LINE", "St_VisualMode" },
["Vs"] = { "V-LINE (Ctrl O)", "St_VisualMode" },
[""] = { "V-BLOCK", "St_VisualMode" },
["R"] = { "REPLACE", "St_ReplaceMode" },
["Rv"] = { "V-REPLACE", "St_ReplaceMode" },
["s"] = { "SELECT", "St_SelectMode" },
["S"] = { "S-LINE", "St_SelectMode" },
[""] = { "S-BLOCK", "St_SelectMode" },
["c"] = { "COMMAND", "St_CommandMode" },
["cv"] = { "COMMAND", "St_CommandMode" },
["ce"] = { "COMMAND", "St_CommandMode" },
["r"] = { "PROMPT", "St_ConfirmMode" },
["rm"] = { "MORE", "St_ConfirmMode" },
["r?"] = { "CONFIRM", "St_ConfirmMode" },
["!"] = { "SHELL", "St_TerminalMode" },
}
local function is_dapmode()
return require("sp4ke.dapmode").is_active()
-- return false
end
return {
mode = function()
local m = vim.api.nvim_get_mode().mode
local current_mode = "%#" .. modes[m][2] .. "#" .. "" .. modes[m][1]
local mode_sep1 = "%#" .. modes[m][2] .. "Sep" .. "#" .. sep_r
if is_dapmode() then
local dap_mode = "%#St_DapMode#DEBUG" .. "%#St_DapModeSep#"
return current_mode .. mode_sep1 .. "%#St_DapModeSep2#" .. sep_r .. dap_mode .. sep_r
end
return current_mode .. mode_sep1 .. "%#ST_EmptySpace#" .. sep_r
end,
fileInfo = function ()
local icon = ""
local filename = (fn.expand "%" == "" and "Empty ") or fn.expand "%:t"
@ -43,6 +92,29 @@ return {
info = (info and info > 0) and ("%#St_lspInfo#" .. myicons.lsp.diagnostic_info .. " " .. info .. " ") or ""
return errors .. warnings .. hints .. info
end
end,
LSP_status = function()
local lsp_status = ""
local dap_status = ""
if rawget(vim, "lsp") then
for _, client in ipairs(vim.lsp.get_active_clients()) do
if client.attached_buffers[vim.api.nvim_get_current_buf()] then
lsp_status = (vim.o.columns > 100 and "%#St_LspStatus#" .. "  [" .. client.name .. "] ") or ""
end
end
end
local present, dap = pcall(require, "dap")
if present then
local session = dap.session()
if session ~= nil and session.initialized == true then
dap_status = "%#St_Dap#" .. "%* "
end
end
return lsp_status .. dap_status
end,
}

@ -0,0 +1,33 @@
local dapmode = require("sp4ke.dapmode")
local M = {}
local function register_listeners()
local present, dap = pcall(require, "dap")
if not present then
print("nvim-dap missing !")
return
end
dap.listeners.before['event_initialized']['sp4ke-dap'] = function(session, body)
dapmode.start()
end
dap.listeners.after['event_terminated']['sp4ke-dap'] = function(session, body)
-- print("dap session ended")
dapmode.stop()
end
end
function M.go_debug()
local present, gdap = pcall(require, "go.dap")
if not present then return end
gdap.run()
end
function M.setup()
dapmode.setup({})
register_listeners()
end
return M

@ -0,0 +1,96 @@
local libmodal = require "libmodal"
M = {}
M.layer = nil
local config = {
mappings = {
n =
{
t = { rhs = '<cmd> DapToggleBreakpoint<CR>', desc= "[dap] toggle breakpoint" },
T = {
rhs = function()
require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))
end,
desc = "[dap] conditional breakpoint",
},
c = {
rhs = function()
require('dap').continue()
end,
desc = "[dap] continue"
},
n = {
rhs = function()
require('dap').step_over()
end,
desc = "[dap] step over"
},
s = {
rhs = function()
require('dap').step_into()
end,
desc = '[dap] step into'
},
o = {
rhs = function()
require('dap').step_out()
end,
desc = '[dap] step out'
},
r = {
rhs = function()
require('go.dap').run()
end,
desc = '[dap] run'
},
S = {
rhs = function()
require('go.dap').stop()
end,
desc = "[dap] stop"
},
C = {
rhs = function()
require('dap').run_to_cursor()
end,
desc = "[dap] run to curosr"
},
["Q"] = {
rhs = function()
M.layer:exit()
end,
desc = "[dap] exit dap mode"
}
}
}
}
function M.start()
if M.layer == nil then
M.layer = libmodal.layer.new(config.mappings)
end
M.layer:enter()
end
function M.stop()
if M.layer ~= nil then M.layer:exit() end
end
function M.setup (opts)
config = vim.tbl_deep_extend("force", config, opts or {})
end
function M.is_active()
if M.layer == nil then return false end
return M.layer:is_active()
end
-- layer:map('n', '<Esc>', function() layer:exit() end, {})
-- --
-- layer:enter()
--
return M

@ -4,7 +4,7 @@
" MattesGroeger/vim-bookmarks
let g:bookmark_sign = ''
let g:bookmark_annotation_sign = ''
let g:bookmark_annotation_sign = ''
let g:bookmark_no_default_key_mappings = 1
let g:bookmark_highlight_lines = 0
let g:bookmark_auto_save = 1

Loading…
Cancel
Save