nvim: set up nvim-navic

This commit is contained in:
Daniel Lundin 2022-12-27 18:49:51 +01:00
parent bab0d9cb20
commit cae9db14d4
3 changed files with 164 additions and 142 deletions

View file

@ -1,122 +1,130 @@
return { return {
"hashivim/vim-terraform", "hashivim/vim-terraform",
"pierreglaser/folding-nvim", "pierreglaser/folding-nvim",
"tjdevries/colorbuddy.vim", "tjdevries/colorbuddy.vim",
"wbthomason/packer.nvim", "wbthomason/packer.nvim",
"jose-elias-alvarez/nvim-lsp-ts-utils", "jose-elias-alvarez/nvim-lsp-ts-utils",
"jjo/vim-cue", "jjo/vim-cue",
"ckipp01/stylua-nvim", "ckipp01/stylua-nvim",
{ {
"numToStr/Comment.nvim", "SmiteshP/nvim-navic",
keys = { config = function()
{ "<C-_>", "<Plug>(comment_toggle_linewise_current)" }, vim.g.navic_silence = true
{ "<C-_>", "<Plug>(comment_toggle_linewise_visual)", mode = "v" }, require("nvim-navic").setup({ separator = " ", highlight = true, depth_limit = 5 })
}, end,
dependencies = { },
"JoosepAlviste/nvim-ts-context-commentstring",
},
config = function()
require("Comment").setup({
pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(),
})
end,
},
{ {
"L3MON4D3/LuaSnip", "numToStr/Comment.nvim",
config = function() keys = {
require("luasnip/loaders/from_vscode").lazy_load() { "<C-_>", "<Plug>(comment_toggle_linewise_current)" },
end, { "<C-_>", "<Plug>(comment_toggle_linewise_visual)", mode = "v" },
}, },
dependencies = {
"JoosepAlviste/nvim-ts-context-commentstring",
},
config = function()
require("Comment").setup({
pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(),
})
end,
},
{ {
"lewis6991/gitsigns.nvim", "L3MON4D3/LuaSnip",
dependencies = { config = function()
"nvim-lua/plenary.nvim", require("luasnip/loaders/from_vscode").lazy_load()
}, end,
config = function() },
require("gitsigns").setup({
numhl = true,
signs = {
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
change = {
hl = "GitSignsChange",
text = "",
numhl = "GitSignsChangeNr",
linehl = "GitSignsChangeLn",
},
delete = {
hl = "GitSignsDelete",
text = "",
numhl = "GitSignsDeleteNr",
linehl = "GitSignsDeleteLn",
},
topdelete = {
hl = "GitSignsDelete",
text = "",
numhl = "GitSignsDeleteNr",
linehl = "GitSignsDeleteLn",
},
changedelete = {
hl = "GitSignsChange",
text = "~",
numhl = "GitSignsChangeNr",
linehl = "GitSignsChangeLn",
},
},
})
end,
},
{ {
"lukas-reineke/indent-blankline.nvim", "lewis6991/gitsigns.nvim",
branch = "master", dependencies = {
event = "VeryLazy", "nvim-lua/plenary.nvim",
init = function() },
vim.g.indent_blankline_char = "" config = function()
vim.g.indent_blankline_space_char = "" require("gitsigns").setup({
vim.g.indent_blankline_space_char_highlight_list = { "IndentSpace" } numhl = true,
-- vim.g.indent_blankline_char_list = {'|', '¦', '┆', '┊'} signs = {
vim.g.indent_blankline_buftype_exclude = { "help", "terminal" } add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
vim.g.indent_blankline_filetype_exclude = { "text", "markdown" } change = {
-- vim.g.indent_blankline_show_end_of_line = true hl = "GitSignsChange",
vim.g.indent_blankline_show_first_indent_level = true text = "",
vim.g.indent_blankline_show_trailing_blankline_indent = true numhl = "GitSignsChangeNr",
vim.g.indent_blankline_char_highlight_list = linehl = "GitSignsChangeLn",
{ "Indent1", "Indent2", "Indent3", "Indent4", "Indent5", "Indent6" } },
require("indent_blankline").setup({}) delete = {
end, hl = "GitSignsDelete",
}, text = "",
numhl = "GitSignsDeleteNr",
linehl = "GitSignsDeleteLn",
},
topdelete = {
hl = "GitSignsDelete",
text = "",
numhl = "GitSignsDeleteNr",
linehl = "GitSignsDeleteLn",
},
changedelete = {
hl = "GitSignsChange",
text = "~",
numhl = "GitSignsChangeNr",
linehl = "GitSignsChangeLn",
},
},
})
end,
},
{ {
"ray-x/go.nvim", "lukas-reineke/indent-blankline.nvim",
config = function() branch = "master",
require("go").setup({ event = "VeryLazy",
comment_placeholder = "", init = function()
icons = { breakpoint = "🧘", currentpos = "🏃" }, vim.g.indent_blankline_char = ""
dap_debug_gui = false, vim.g.indent_blankline_space_char = ""
}) vim.g.indent_blankline_space_char_highlight_list = { "IndentSpace" }
vim.cmd("autocmd FileType go nmap <Leader>c :lua require('go.comment').gen()<cr>") -- vim.g.indent_blankline_char_list = {'|', '¦', '┆', '┊'}
vim.cmd("autocmd BufWritePre *.go :silent! lua require('go.format').gofmt()") vim.g.indent_blankline_buftype_exclude = { "help", "terminal" }
vim.cmd("autocmd BufWritePre (InsertLeave?) <buffer> lua vim.lsp.buf.formatting_sync(nil,500)") vim.g.indent_blankline_filetype_exclude = { "text", "markdown" }
end, -- vim.g.indent_blankline_show_end_of_line = true
}, vim.g.indent_blankline_show_first_indent_level = true
vim.g.indent_blankline_show_trailing_blankline_indent = true
vim.g.indent_blankline_char_highlight_list =
{ "Indent1", "Indent2", "Indent3", "Indent4", "Indent5", "Indent6" }
require("indent_blankline").setup({})
end,
},
{ {
"onsails/lspkind-nvim", "ray-x/go.nvim",
config = function() config = function()
require("lspkind").init({}) require("go").setup({
end, comment_placeholder = "",
}, icons = { breakpoint = "🧘", currentpos = "🏃" },
dap_debug_gui = false,
})
vim.cmd("autocmd FileType go nmap <Leader>c :lua require('go.comment').gen()<cr>")
vim.cmd("autocmd BufWritePre *.go :silent! lua require('go.format').gofmt()")
vim.cmd("autocmd BufWritePre (InsertLeave?) <buffer> lua vim.lsp.buf.formatting_sync(nil,500)")
end,
},
{ {
url = "https://git.sr.ht/~whynothugo/lsp_lines.nvim", "onsails/lspkind-nvim",
config = function() config = function()
require("lsp_lines").setup() require("lspkind").init({})
vim.diagnostic.config({ end,
virtual_text = false, },
})
end, {
}, url = "https://git.sr.ht/~whynothugo/lsp_lines.nvim",
config = function()
require("lsp_lines").setup()
vim.diagnostic.config({
virtual_text = false,
})
end,
},
} }

View file

@ -45,8 +45,8 @@ function M.config()
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end end
local on_attach = function() local function on_attach(client, bufnr)
-- require("folding").on_attach() require("nvim-navic").attach(client, bufnr)
end end
-- simple setups -- -- simple setups --
@ -86,8 +86,8 @@ function M.config()
}) })
lspconfig.sumneko_lua.setup({ lspconfig.sumneko_lua.setup({
on_attach = function() on_attach = function(client, bufnr)
on_attach() on_attach(client, bufnr)
vim.cmd([[autocmd BufWritePre <buffer> lua require'stylua-nvim'.format_file()]]) vim.cmd([[autocmd BufWritePre <buffer> lua require'stylua-nvim'.format_file()]])
end, end,
settings = { settings = {

View file

@ -1,36 +1,50 @@
local M = { local M = {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
dependencies = { "kyazdani42/nvim-web-devicons" }, dependencies = { "kyazdani42/nvim-web-devicons" },
event = "VeryLazy", event = "VeryLazy",
} }
local function clock() local function clock()
return os.date("%H:%M") return os.date("%H:%M")
end end
function M.config() function M.config()
local lualine = require("lualine") local lualine = require("lualine")
lualine.setup({ lualine.setup({
options = { options = {
globalstatus = true, globalstatus = true,
theme = "onelight", theme = "onelight",
component_separators = { left = "", right = "" }, component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" }, section_separators = { left = "", right = "" },
}, },
sections = { sections = {
lualine_c = { lualine_c = {
{ {
"filename", "filename",
path = 1, path = 1,
file_status = true, file_status = true,
}, },
}, {
lualine_x = { "filetype" }, function()
lualine_y = { "location", "progress" }, local navic = require("nvim-navic")
lualine_z = { clock }, local ret = navic.get_location()
}, return ret:len() > 2000 and "navic error" or ret
}) end,
cond = function()
if package.loaded["nvim-navic"] then
local navic = require("nvim-navic")
return navic.is_available()
end
end,
color = { fg = "#d66622" },
},
},
lualine_x = { "filetype" },
lualine_y = { "location", "progress" },
lualine_z = { clock },
},
})
end end
return M return M