setup neovim winbar
This commit is contained in:
parent
636203b151
commit
26b36f6200
7 changed files with 84 additions and 24 deletions
|
@ -20,5 +20,4 @@ require("user.alpha")
|
|||
require("user.whichkey")
|
||||
require("user.trouble")
|
||||
require("user.colorizer")
|
||||
require("user.gps")
|
||||
require("user.discord")
|
||||
|
|
|
@ -70,6 +70,11 @@ end
|
|||
M.on_attach = function(client, bufnr)
|
||||
lsp_keymaps(bufnr)
|
||||
lsp_highlight_document(client)
|
||||
|
||||
if client.server_capabilities.documentSymbolProvider then
|
||||
local navic = require("nvim-navic")
|
||||
navic.attach(client, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
|
|
|
@ -3,20 +3,6 @@ if not status_ok then
|
|||
return
|
||||
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({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
|
@ -29,7 +15,7 @@ lualine.setup({
|
|||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_c = { "filename", "filesize", nvim_gps },
|
||||
lualine_c = { "filename", "filesize" },
|
||||
lualine_x = { "encoding", "fileformat", "filetype" },
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = { "location" },
|
||||
|
@ -43,5 +29,10 @@ lualine.setup({
|
|||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {},
|
||||
extensions = {
|
||||
"nvim-tree",
|
||||
"toggleterm",
|
||||
"fzf",
|
||||
"quickfix",
|
||||
},
|
||||
})
|
||||
|
|
|
@ -36,6 +36,7 @@ vim.opt.incsearch = true
|
|||
vim.opt.colorcolumn = "120"
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars:append("lead:.")
|
||||
vim.opt.winbar = "%{%v:lua.require'user.winbar'.get_winbar()%}"
|
||||
|
||||
vim.cmd("set whichwrap+=<,>,[,],h,l")
|
||||
vim.cmd([[set iskeyword+=-]])
|
||||
|
|
|
@ -131,8 +131,8 @@ return packer.startup(function(use)
|
|||
-- Colorizer
|
||||
use("norcalli/nvim-colorizer.lua")
|
||||
|
||||
-- GPS
|
||||
use("SmiteshP/nvim-gps")
|
||||
-- Navic
|
||||
use("SmiteshP/nvim-navic")
|
||||
|
||||
-- Wakatime
|
||||
use("wakatime/vim-wakatime")
|
||||
|
|
64
.config/nvim/lua/user/winbar.lua
Normal file
64
.config/nvim/lua/user/winbar.lua
Normal 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
|
|
@ -194,11 +194,6 @@ _G.packer_plugins = {
|
|||
path = "/home/relms/.local/share/nvim/site/pack/packer/start/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"] = {
|
||||
loaded = true,
|
||||
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",
|
||||
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"] = {
|
||||
loaded = true,
|
||||
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",
|
||||
|
|
Reference in a new issue