diff --git a/init.lua b/init.lua index 0134b6b..b7aede6 100644 --- a/init.lua +++ b/init.lua @@ -2,6 +2,7 @@ require("user.options") require("user.keymaps") require("user.plugins") require("user.notify") +require("user.navic") require("user.cmp") require("user.lsp") require("user.colorscheme") @@ -26,3 +27,6 @@ require("user.spectre") require("user.dap") require("user.copilot") require("user.dressing") +require("user.cybu") +require("user.autocommands") +require("user.gps") diff --git a/lua/user/bufferline.lua b/lua/user/bufferline.lua index 777afa3..4db41ff 100644 --- a/lua/user/bufferline.lua +++ b/lua/user/bufferline.lua @@ -21,7 +21,7 @@ bufferline.setup({ tab_size = 21, diagnostics = "nvim_lsp", diagnostics_update_in_insert = true, - offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, + offsets = { { filetype = "NvimTree", text = "" } }, show_buffer_icons = true, show_buffer_close_icons = true, show_close_icon = true, diff --git a/lua/user/cybu.lua b/lua/user/cybu.lua new file mode 100644 index 0000000..c971e7b --- /dev/null +++ b/lua/user/cybu.lua @@ -0,0 +1,24 @@ +local ok, cybu = pcall(require, "cybu") +if not ok then + return +end + +cybu.setup({ + display_time = 1750, -- time the cybu window is displayed + style = { + path = "relative", -- absolute, relative, tail (filename only) + border = "rounded", -- single, double, rounded, none + separator = " ", -- string used as separator + prefix = "…", -- string used as prefix for truncated paths + padding = 1, -- left & right padding in number of spaces + hide_buffer_id = true, + devicons = { + enabled = true, -- enable or disable web dev icons + colored = true, -- enable color for web dev icons + }, + }, +}) + +vim.keymap.set("n", "", "(CybuPrev)") +vim.keymap.set("n", "", "(CybuNext)") +vim.keymap.set("n", "", "") diff --git a/lua/user/dap.lua b/lua/user/dap.lua index b4cbd4c..daf3ea0 100644 --- a/lua/user/dap.lua +++ b/lua/user/dap.lua @@ -3,10 +3,10 @@ if not dapui_status_ok then return end -local vtest_status_ok, vtest = pcall(require, "nvim-dap-virtual-text") -if not vtest_status_ok then +local vtext_status_ok, vtext = pcall(require, "nvim-dap-virtual-text") +if not vtext_status_ok then return end dapui.setup() -vtest.setup() +vtext.setup() diff --git a/lua/user/gps.lua b/lua/user/gps.lua new file mode 100644 index 0000000..6b9deba --- /dev/null +++ b/lua/user/gps.lua @@ -0,0 +1,33 @@ +local status_ok, gps = pcall(require, "nvim-gps") +if not status_ok then + return +end + +gps.setup({ + icons = { + ["class-name"] = " ", + ["function-name"] = " ", + ["method-name"] = " ", + ["container-name"] = "⛶ ", + ["tag-name"] = "炙 ", + ["mapping-name"] = " ", + ["sequence-name"] = " ", + ["null-name"] = "[] ", + ["boolean-name"] = "ﰰﰴ ", + ["integer-name"] = "# ", + ["float-name"] = " ", + ["string-name"] = " ", + ["array-name"] = " ", + ["object-name"] = " ", + ["number-name"] = "# ", + ["table-name"] = " ", + ["date-name"] = " ", + ["date-time-name"] = " ", + ["inline-table-name"] = " ", + ["time-name"] = " ", + ["module-name"] = " ", + }, + separator = " > ", + depth = 0, + depth_limit_indicator = "..", +}) diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua index 1a42e9f..2dbd904 100644 --- a/lua/user/keymaps.lua +++ b/lua/user/keymaps.lua @@ -70,7 +70,7 @@ keymap("n", "duh", ":lua require('dap.ui.widgets').hover()", opts) keymap( "n", "duf", - ":lua local widgets=require('dap.ui.widgets');widgets.centered_float(widgets.scopes)", + ":lua local widgets=require('dap.ui.widgets').widgets.centered_float(widgets.scopes)", opts ) keymap("n", "dro", ":lua require('dap').repl.open()", opts) diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua index 450f854..98a2394 100644 --- a/lua/user/lsp/handlers.lua +++ b/lua/user/lsp/handlers.lua @@ -41,6 +41,15 @@ M.setup = function() }) end +local function attach_navic(client, bufnr) + vim.g.navic_silence = false + local status_ok, navic = pcall(require, "nvim-navic") + if not status_ok then + return + end + navic.attach(client, bufnr) +end + local function lsp_highlight_document(client) local status_ok, illuminate = pcall(require, "illuminate") if not status_ok then @@ -68,6 +77,7 @@ end M.on_attach = function(client, bufnr) lsp_keymaps(bufnr) lsp_highlight_document(client) + attach_navic(client, bufnr) end local capabilities = vim.lsp.protocol.make_client_capabilities() diff --git a/lua/user/lsp/nullls.lua b/lua/user/lsp/nullls.lua index c469a8c..2d08457 100644 --- a/lua/user/lsp/nullls.lua +++ b/lua/user/lsp/nullls.lua @@ -13,7 +13,6 @@ null_ls.setup({ formatting.stylua, code_actions.eslint_d, diagnostics.eslint_d, - diagnostics.cspell, formatting.eslint_d, }, on_attach = function(client) diff --git a/lua/user/lualine.lua b/lua/user/lualine.lua index 84d2335..0f3847e 100644 --- a/lua/user/lualine.lua +++ b/lua/user/lualine.lua @@ -34,5 +34,6 @@ lualine.setup({ "toggleterm", "fzf", "quickfix", + "nvim-dap-ui", }, }) diff --git a/lua/user/navic.lua b/lua/user/navic.lua new file mode 100644 index 0000000..647e6ad --- /dev/null +++ b/lua/user/navic.lua @@ -0,0 +1,34 @@ +local status_ok, navic = pcall(require, "nvim-navic") +if not status_ok then + return +end + +navic.setup({ + icons = { + ["class-name"] = " ", + ["function-name"] = " ", + ["method-name"] = " ", + ["container-name"] = "⛶ ", + ["tag-name"] = "炙 ", + ["mapping-name"] = " ", + ["sequence-name"] = " ", + ["null-name"] = "[] ", + ["boolean-name"] = "ﰰﰴ ", + ["integer-name"] = "# ", + ["float-name"] = " ", + ["string-name"] = " ", + ["array-name"] = " ", + ["object-name"] = " ", + ["number-name"] = "# ", + ["table-name"] = " ", + ["date-name"] = " ", + ["date-time-name"] = " ", + ["inline-table-name"] = " ", + ["time-name"] = " ", + ["module-name"] = " ", + }, + highlight = true, + separator = " > ", + depth_limit = 0, + depth_limit_indicator = "..", +}) diff --git a/lua/user/options.lua b/lua/user/options.lua index dad6ca3..a6eae2f 100644 --- a/lua/user/options.lua +++ b/lua/user/options.lua @@ -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+=-]]) diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua index 70faaaf..9f1804b 100644 --- a/lua/user/plugins.lua +++ b/lua/user/plugins.lua @@ -74,6 +74,7 @@ return packer.startup(function(use) use("onsails/lspkind.nvim") use("glepnir/lspsaga.nvim") use("Maan2003/lsp_lines.nvim") + use("SmiteshP/nvim-navic") -- Telescope use("nvim-telescope/telescope.nvim") @@ -84,6 +85,7 @@ return packer.startup(function(use) use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }) use("p00f/nvim-ts-rainbow") use("JoosepAlviste/nvim-ts-context-commentstring") + use("SmiteshP/nvim-gps") -- Autopairs use("windwp/nvim-autopairs") @@ -155,6 +157,7 @@ return packer.startup(function(use) -- UI use("stevearc/dressing.nvim") + use("ghillb/cybu.nvim") -- Undo Tree use("mbbill/undotree") diff --git a/lua/user/winbar.lua b/lua/user/winbar.lua new file mode 100644 index 0000000..e2c0724 --- /dev/null +++ b/lua/user/winbar.lua @@ -0,0 +1,87 @@ +local M = {} + +local navic = require("nvim-navic") +local gps = require("nvim-gps") + +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() + local gps_location = gps.get_location() + + if not is_empty(location) then + return "%#WinBarContext#" .. " " .. ">" .. " " .. location .. "%*" + elseif not is_empty(gps_location) then + return "%#WinBarContext#" .. " " .. ">" .. " " .. gps_location .. "%*" + else + return "" + end +end + +local function get_fileicon() + local hl_winbar_file_icon = "WinBarFileIcon" + local file_path = vim.fn.expand("%:~:.:h") + local filename = vim.fn.expand("%:t") + local file_type = vim.fn.expand("%:e") + local file_icon = "" + local file_icon_color = "" + + file_path = file_path:gsub("^%.", "") + file_path = file_path:gsub("^%/", "") + + if not is_empty(filename) then + local default = false + + if is_empty(file_type) then + file_type = "" + default = true + end + file_icon, file_icon_color = + require("nvim-web-devicons").get_icon_color(filename, file_type, { default = default }) + vim.api.nvim_set_hl(0, hl_winbar_file_icon, { fg = file_icon_color }) + end + + return "%#WinBarContext#" .. "%#" .. hl_winbar_file_icon .. "#" .. file_icon .. " " .. "%*" +end + +function M.get_winbar() + if excludes() then + return "" + end + if navic.is_available() then + return get_fileicon() .. get_filename() .. get_location() + else + return get_fileicon() .. get_filename() + end +end + +return M