Archived
0
0
Fork 0

setup neovim winbar

This commit is contained in:
Daryl Ronningen 2022-06-28 23:40:34 +08:00
parent 636203b151
commit 26b36f6200
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
7 changed files with 84 additions and 24 deletions

View file

@ -20,5 +20,4 @@ require("user.alpha")
require("user.whichkey") require("user.whichkey")
require("user.trouble") require("user.trouble")
require("user.colorizer") require("user.colorizer")
require("user.gps")
require("user.discord") require("user.discord")

View file

@ -70,6 +70,11 @@ end
M.on_attach = function(client, bufnr) M.on_attach = function(client, bufnr)
lsp_keymaps(bufnr) lsp_keymaps(bufnr)
lsp_highlight_document(client) lsp_highlight_document(client)
if client.server_capabilities.documentSymbolProvider then
local navic = require("nvim-navic")
navic.attach(client, bufnr)
end
end end
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()

View file

@ -3,20 +3,6 @@ if not status_ok then
return return
end end
local status_gps_ok, gps = pcall(require, "nvim-gps")
if not status_gps_ok then
return
end
local nvim_gps = function()
local gps_location = gps.get_location()
if gps_location == "error" then
return ""
else
return gps.get_location()
end
end
lualine.setup({ lualine.setup({
options = { options = {
icons_enabled = true, icons_enabled = true,
@ -29,7 +15,7 @@ lualine.setup({
sections = { sections = {
lualine_a = { "mode" }, lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" }, lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename", "filesize", nvim_gps }, lualine_c = { "filename", "filesize" },
lualine_x = { "encoding", "fileformat", "filetype" }, lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" }, lualine_y = { "progress" },
lualine_z = { "location" }, lualine_z = { "location" },
@ -43,5 +29,10 @@ lualine.setup({
lualine_z = {}, lualine_z = {},
}, },
tabline = {}, tabline = {},
extensions = {}, extensions = {
"nvim-tree",
"toggleterm",
"fzf",
"quickfix",
},
}) })

View file

@ -36,6 +36,7 @@ vim.opt.incsearch = true
vim.opt.colorcolumn = "120" vim.opt.colorcolumn = "120"
vim.opt.list = true vim.opt.list = true
vim.opt.listchars:append("lead:.") vim.opt.listchars:append("lead:.")
vim.opt.winbar = "%{%v:lua.require'user.winbar'.get_winbar()%}"
vim.cmd("set whichwrap+=<,>,[,],h,l") vim.cmd("set whichwrap+=<,>,[,],h,l")
vim.cmd([[set iskeyword+=-]]) vim.cmd([[set iskeyword+=-]])

View file

@ -131,8 +131,8 @@ return packer.startup(function(use)
-- Colorizer -- Colorizer
use("norcalli/nvim-colorizer.lua") use("norcalli/nvim-colorizer.lua")
-- GPS -- Navic
use("SmiteshP/nvim-gps") use("SmiteshP/nvim-navic")
-- Wakatime -- Wakatime
use("wakatime/vim-wakatime") use("wakatime/vim-wakatime")

View file

@ -0,0 +1,64 @@
local M = {}
local navic = require("nvim-navic")
local function get_buf_option(opt)
local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt)
if not status_ok then
return nil
else
return buf_option
end
end
local function is_empty(s)
return s == nil or s == ""
end
M.winbar_filetype_exclude = {
"help",
"startify",
"dashboard",
"packer",
"neogitstatus",
"NvimTree",
"Trouble",
"alpha",
"lir",
"Outline",
"spectre_panel",
"toggleterm",
}
local excludes = function()
if vim.tbl_contains(M.winbar_filetype_exclude, vim.bo.filetype) then
vim.opt_local.winbar = nil
return true
end
return false
end
local function get_filename()
return "%#WinBarFilename#" .. "%t" .. "%*"
end
local function get_location()
local location = navic.get_location()
if not is_empty(location) then
return "%#WinBarContext#" .. " " .. ">" .. " " .. location .. "%*"
end
return ""
end
function M.get_winbar()
if excludes() then
return ""
end
if navic.is_available() then
return get_filename() .. get_location()
else
return get_filename()
end
end
return M

View file

@ -194,11 +194,6 @@ _G.packer_plugins = {
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua", path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua",
url = "https://github.com/norcalli/nvim-colorizer.lua" url = "https://github.com/norcalli/nvim-colorizer.lua"
}, },
["nvim-gps"] = {
loaded = true,
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-gps",
url = "https://github.com/SmiteshP/nvim-gps"
},
["nvim-lsp-installer"] = { ["nvim-lsp-installer"] = {
loaded = true, loaded = true,
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer", path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer",
@ -209,6 +204,11 @@ _G.packer_plugins = {
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig" url = "https://github.com/neovim/nvim-lspconfig"
}, },
["nvim-navic"] = {
loaded = true,
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-navic",
url = "https://github.com/SmiteshP/nvim-navic"
},
["nvim-tree.lua"] = { ["nvim-tree.lua"] = {
loaded = true, loaded = true,
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",