Improve startuptime | remove un-needed plugins | lazy load plugin highlights too

removed nvim-gps as nvim-navic or winbar.nvim will be added when v0.8 neovim releases. Removed lsp signature as I was able to emulate showing args with the default signature help() window
This commit is contained in:
siduck 2022-06-14 17:36:27 +05:30
parent d42ffe1ac7
commit 0bde81a074
21 changed files with 463 additions and 391 deletions

View File

@ -1,9 +1,3 @@
local present, impatient = pcall(require, "impatient")
if present then
impatient.enable_profile()
end
require "core" require "core"
require "core.utils" require "core.utils"
require "core.options" require "core.options"

111
lua/core/lazy_load.lua Normal file
View File

@ -0,0 +1,111 @@
-- https://github.com/max397574/omega-nvim/blob/master/lua/omega/modules/ui/bufferline.lua
local lazy_load = function(tb)
vim.api.nvim_create_autocmd(tb.events, {
pattern = "*",
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
callback = function()
if tb.condition() then
vim.api.nvim_del_augroup_by_name(tb.augroup_name)
-- dont defer for treesitter as it will show slow highlighting
-- This deferring only happens only when we do "nvim filename"
if tb.plugins ~= "nvim-treesitter" then
vim.defer_fn(function()
vim.cmd("PackerLoad " .. tb.plugins)
end, 0)
else
vim.cmd("PackerLoad " .. tb.plugins)
end
end
end,
})
end
local M = {}
M.bufferline = function()
lazy_load {
events = { "BufNewFile", "BufAdd", "TabEnter" },
augroup_name = "BufferLineLazy",
plugins = "bufferline.nvim",
condition = function()
return #vim.fn.getbufinfo { buflisted = 1 } >= 2
end,
}
end
M.colorizer = function()
lazy_load {
events = { "BufRead", "BufNewFile" },
augroup_name = "ColorizerLazy",
plugins = "nvim-colorizer.lua",
condition = function()
local items = { "#", "rgb", "hsl" }
for _, val in ipairs(items) do
if vim.fn.search(val) ~= 0 then
return true
end
end
end,
}
end
-- load certain plugins only when there's a file opened in the buffer
-- if "nvim-file" is executed -> load the plugin after nvim gui loads
-- This gives an instant preview of nvim with the file opened
M.on_file_open = function()
lazy_load {
events = { "BufRead", "BufWinEnter", "BufNewFile" },
augroup_name = "BeLazyOnFileOpen",
plugins = "nvim-lsp-installer indent-blankline.nvim",
condition = function()
local file = vim.fn.expand "%"
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
end,
}
end
M.treesitter = function()
lazy_load {
events = { "BufRead", "BufWinEnter", "BufNewFile" },
augroup_name = "Treesitter_lazy",
plugins = "nvim-treesitter",
condition = function()
local file = vim.fn.expand "%"
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
end,
}
end
M.gitsigns = function()
-- taken from https://github.com/max397574
vim.api.nvim_create_autocmd({ "BufAdd", "VimEnter" }, {
callback = function()
local function onexit(code, _)
if code == 0 then
vim.schedule(function()
require("packer").loader "gitsigns.nvim"
end)
end
end
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
if lines ~= { "" } then
vim.loop.spawn("git", {
args = {
"ls-files",
"--error-unmatch",
vim.fn.expand "%",
},
}, onexit)
end
end,
})
end
return M

View File

@ -1,15 +1,15 @@
local opt = vim.opt local opt = vim.opt
local g = vim.g local g = vim.g
local config = require("core.utils").load_config() local config = require("core.utils").load_config()
g.nvchad_theme = config.ui.theme g.nvchad_theme = config.ui.theme
g.toggle_theme_icon = ""
g.transparency = config.ui.transparency
g.theme_switcher_loaded = false
-- use filetype.lua instead of filetype.vim -- use filetype.lua instead of filetype.vim
g.did_load_filetypes = 0 g.did_load_filetypes = 0
g.do_filetype_lua = 1 g.do_filetype_lua = 1
g.toggle_theme_icon = ""
g.transparency = config.ui.transparency
opt.laststatus = 3 -- global statusline opt.laststatus = 3 -- global statusline
opt.statusline = config.plugins.options.statusline.config opt.statusline = config.plugins.options.statusline.config
@ -76,6 +76,19 @@ local default_plugins = {
"vimballPlugin", "vimballPlugin",
"zip", "zip",
"zipPlugin", "zipPlugin",
"python3_provider",
"python_provider",
"node_provider",
"ruby_provider",
"perl_provider",
"tutor",
"rplugin",
"syntax",
"synmenu",
"optwin",
"compiler",
"bugreport",
"ftplugin",
} }
for _, plugin in pairs(default_plugins) do for _, plugin in pairs(default_plugins) do

View File

@ -114,13 +114,6 @@ M.load_mappings = function(mappings, mapping_opt)
end end
end end
-- load plugin after entering vim ui
M.packer_lazy_load = function(plugin)
vim.defer_fn(function()
require("packer").loader(plugin)
end, 0)
end
-- remove plugins defined in chadrc -- remove plugins defined in chadrc
M.remove_default_plugins = function(plugins) M.remove_default_plugins = function(plugins)
local removals = M.load_config().plugins.remove or {} local removals = M.load_config().plugins.remove or {}

View File

@ -4,6 +4,8 @@ if not present then
return return
end end
require("base46").load_highlight "alpha"
local function button(sc, txt, keybind) local function button(sc, txt, keybind)
local sc_ = sc:gsub("%s", ""):gsub("SPC", "<leader>") local sc_ = sc:gsub("%s", ""):gsub("SPC", "<leader>")

View File

@ -4,6 +4,8 @@ if not present then
return return
end end
require("base46").load_highlight "bufferline"
vim.cmd [[ vim.cmd [[
function! Toggle_theme(a,b,c,d) function! Toggle_theme(a,b,c,d)
lua require('base46').toggle_theme() lua require('base46').toggle_theme()

View File

@ -4,6 +4,8 @@ if not present then
return return
end end
require("base46").load_highlight "cmp"
vim.opt.completeopt = "menuone,noselect" vim.opt.completeopt = "menuone,noselect"
local function border(hl_name) local function border(hl_name)
@ -45,9 +47,8 @@ local options = {
}, },
formatting = { formatting = {
format = function(_, vim_item) format = function(_, vim_item)
local icons = require "plugins.configs.lspkind_icons" local icons = require("ui.icons").lspkind
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
return vim_item return vim_item
end, end,
}, },

View File

@ -1,39 +0,0 @@
local present, gps = pcall(require, "nvim-gps")
if not present then
return
end
local icons = require "plugins.configs.lspkind_icons"
local options = {
depth = 5,
icons = {
["class-name"] = "%#GpsItemKindClass#" .. icons.Class .. "%*" .. " ",
["function-name"] = "%#GpsItemKindFunction#" .. icons.Function .. "%*" .. " ",
["method-name"] = "%#GpsItemKindMethod#" .. icons.Method .. "%*" .. " ",
["container-name"] = "%#GpsItemKindProperty#" .. icons.Object .. "%*" .. " ",
["tag-name"] = "%#GpsItemKindKeyword#" .. icons.Tag .. "%*" .. " ",
["mapping-name"] = "%#GpsItemKindProperty#" .. icons.Object .. "%*" .. " ",
["sequence-name"] = "%GpsItemKindProperty#" .. icons.Array .. "%*" .. " ",
["null-name"] = "%GpsItemKindField#" .. icons.Field .. "%*" .. " ",
["boolean-name"] = "%GpsItemKindValue#" .. icons.Boolean .. "%*" .. " ",
["integer-name"] = "%GpsItemKindValue#" .. icons.Number .. "%*" .. " ",
["float-name"] = "%GpsItemKindValue#" .. icons.Number .. "%*" .. " ",
["string-name"] = "%GpsItemKindValue#" .. icons.String .. "%*" .. " ",
["array-name"] = "%GpsItemKindProperty#" .. icons.Array .. "%*" .. " ",
["object-name"] = "%GpsItemKindProperty#" .. icons.Object .. "%*" .. " ",
["number-name"] = "%GpsItemKindValue#" .. icons.Number .. "%*" .. " ",
["table-name"] = "%GpsItemKindProperty#" .. icons.Table .. "%*" .. " ",
["date-name"] = "%GpsItemKindValue#" .. icons.Calendar .. "%*" .. " ",
["date-time-name"] = "%GpsItemKindValue#" .. icons.Table .. "%*" .. " ",
["inline-table-name"] = "%GpsItemKindProperty#" .. icons.Calendar .. "%*" .. " ",
["time-name"] = "%GpsItemKindValue#" .. icons.Watch .. "%*" .. " ",
["module-name"] = "%GpsItemKindModule#" .. icons.Module .. "%*" .. " ",
},
}
options = require("core.utils").load_override(options, "SmiteshP/nvim-gps")
gps.setup(options)

View File

@ -1,128 +0,0 @@
local present, devicons = pcall(require, "nvim-web-devicons")
if not present then
return
end
local options = {
override = {
default_icon = {
icon = "",
name = "Default",
},
c = {
icon = "",
name = "c",
},
css = {
icon = "",
name = "css",
},
deb = {
icon = "",
name = "deb",
},
Dockerfile = {
icon = "",
name = "Dockerfile",
},
html = {
icon = "",
name = "html",
},
jpeg = {
icon = "",
name = "jpeg",
},
jpg = {
icon = "",
name = "jpg",
},
js = {
icon = "",
name = "js",
},
kt = {
icon = "󱈙",
name = "kt",
},
lock = {
icon = "",
name = "lock",
},
lua = {
icon = "",
name = "lua",
},
mp3 = {
icon = "",
name = "mp3",
},
mp4 = {
icon = "",
name = "mp4",
},
out = {
icon = "",
name = "out",
},
png = {
icon = "",
name = "png",
},
py = {
icon = "",
name = "py",
},
["robots.txt"] = {
icon = "",
name = "robots",
},
toml = {
icon = "",
name = "toml",
},
ts = {
icon = "",
name = "ts",
},
ttf = {
icon = "",
name = "TrueTypeFont",
},
rb = {
icon = "",
name = "rb",
},
rpm = {
icon = "",
name = "rpm",
},
vue = {
icon = "",
name = "vue",
},
woff = {
icon = "",
name = "WebOpenFontFormat",
},
woff2 = {
icon = "",
name = "WebOpenFontFormat2",
},
xz = {
icon = "",
name = "xz",
},
zip = {
icon = "",
name = "zip",
},
},
}
-- check for any override
options = require("core.utils").load_override(options, "kyazdani42/nvim-web-devicons")
devicons.setup(options)

View File

@ -4,20 +4,12 @@ if not present then
return return
end end
require("base46").load_highlight "lsp"
local M = {} local M = {}
local utils = require "core.utils" local utils = require "core.utils"
require("plugins.configs.others").lsp_handlers() require "ui.lsp"
-- Borders for LspInfo winodw
local win = require "lspconfig.ui.windows"
local _default_opts = win.default_opts
win.default_opts = function(options)
local opts = _default_opts(options)
opts.border = "single"
return opts
end
M.on_attach = function(client, bufnr) M.on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = false client.resolved_capabilities.document_formatting = false
@ -25,6 +17,16 @@ M.on_attach = function(client, bufnr)
local lsp_mappings = utils.load_config().mappings.lspconfig local lsp_mappings = utils.load_config().mappings.lspconfig
utils.load_mappings({ lsp_mappings }, { buffer = bufnr }) utils.load_mappings({ lsp_mappings }, { buffer = bufnr })
if client.supports_method "textDocument/signatureHelp" then
vim.api.nvim_create_autocmd({ "CursorHoldI" }, {
pattern = "*",
group = vim.api.nvim_create_augroup("LspSignature", {}),
callback = function()
vim.lsp.buf.signature_help()
end,
})
end
end end
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()

View File

@ -1,36 +0,0 @@
return {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
Table = "",
Object = "",
Tag = "",
Array = "",
Boolean = "",
Number = "",
String = "",
Calendar = "",
Watch = "",
}

View File

@ -4,6 +4,8 @@ if not present then
return return
end end
require("base46").load_highlight "nvimtree"
local options = { local options = {
filters = { filters = {
dotfiles = false, dotfiles = false,

View File

@ -4,6 +4,8 @@ if not present then
return return
end end
require "base46.term"
local options = { local options = {
terminals = { terminals = {
list = {}, list = {},

View File

@ -19,28 +19,9 @@ M.autopairs = function()
autopairs.setup(options) autopairs.setup(options)
local cmp_autopairs = require "nvim-autopairs.completion.cmp" local cmp_autopairs = require "nvim-autopairs.completion.cmp"
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end end
M.better_escape = function()
local present, escape = pcall(require, "better_escape")
if not present then
return
end
local options = {
mapping = { "jk" }, -- a table with mappings to use
timeout = vim.o.timeoutlen,
clear_empty_lines = false, -- clear line after escaping if there is only whitespace
keys = "<Esc>",
}
options = load_override(options, "max397574/better-escape.nvim")
escape.setup(options)
end
M.blankline = function() M.blankline = function()
local present, blankline = pcall(require, "indent_blankline") local present, blankline = pcall(require, "indent_blankline")
@ -48,6 +29,8 @@ M.blankline = function()
return return
end end
require("base46").load_highlight "blankline"
local options = { local options = {
indentLine_enabled = 1, indentLine_enabled = 1,
char = "", char = "",
@ -59,7 +42,6 @@ M.blankline = function()
"lspinfo", "lspinfo",
"TelescopePrompt", "TelescopePrompt",
"TelescopeResults", "TelescopeResults",
"nvchad_cheatsheet",
"lsp-installer", "lsp-installer",
"", "",
}, },
@ -99,9 +81,9 @@ M.colorizer = function()
} }
options = load_override(options, "NvChad/nvim-colorizer.lua") options = load_override(options, "NvChad/nvim-colorizer.lua")
colorizer.setup(options["filetypes"], options["user_default_options"]) colorizer.setup(options["filetypes"], options["user_default_options"])
vim.cmd "ColorizerReloadAllBuffers"
vim.cmd "ColorizerAttachToBuffer"
end end
M.comment = function() M.comment = function()
@ -130,79 +112,9 @@ M.luasnip = function()
options = load_override(options, "L3MON4D3/LuaSnip") options = load_override(options, "L3MON4D3/LuaSnip")
luasnip.config.set_config(options) luasnip.config.set_config(options)
require("luasnip.loaders.from_vscode").lazy_load() require("luasnip.loaders.from_vscode").lazy_load()
end end
M.signature = function()
local present, lsp_signature = pcall(require, "lsp_signature")
if not present then
return
end
local options = {
bind = true,
doc_lines = 0,
floating_window = true,
fix_pos = true,
hint_enable = true,
hint_prefix = "",
hint_scheme = "String",
hi_parameter = "Search",
max_height = 22,
max_width = 120, -- max_width of signature floating_window, line will be wrapped if exceed max_width
handler_opts = {
border = "single", -- double, single, shadow, none
},
zindex = 200, -- by default it will be on top of all floating windows, set to 50 send it to bottom
padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc
}
options = load_override(options, "ray-x/lsp_signature.nvim")
lsp_signature.setup(options)
end
M.lsp_handlers = function()
local function lspSymbol(name, icon)
local hl = "DiagnosticSign" .. name
vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl })
end
lspSymbol("Error", "")
lspSymbol("Info", "")
lspSymbol("Hint", "")
lspSymbol("Warn", "")
vim.diagnostic.config {
virtual_text = {
prefix = "",
},
signs = true,
underline = true,
update_in_insert = false,
}
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "single",
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "single",
})
-- suppress error messages from lang servers
vim.notify = function(msg, log_level)
if msg:match "exit code" then
return
end
if log_level == vim.log.levels.ERROR then
vim.api.nvim_err_writeln(msg)
else
vim.api.nvim_echo({ { msg } }, true, {})
end
end
end
M.gitsigns = function() M.gitsigns = function()
local present, gitsigns = pcall(require, "gitsigns") local present, gitsigns = pcall(require, "gitsigns")
@ -210,6 +122,8 @@ M.gitsigns = function()
return return
end end
require("base46").load_highlight "git"
local options = { local options = {
signs = { signs = {
add = { hl = "DiffAdd", text = "", numhl = "GitSignsAddNr" }, add = { hl = "DiffAdd", text = "", numhl = "GitSignsAddNr" },
@ -219,9 +133,21 @@ M.gitsigns = function()
changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" },
}, },
} }
options = load_override(options, "lewis6991/gitsigns.nvim")
options = load_override(options, "lewis6991/gitsigns.nvim")
gitsigns.setup(options) gitsigns.setup(options)
end end
M.devicons = function()
local present, devicons = pcall(require, "nvim-web-devicons")
if present then
require("base46").load_highlight "devicons"
local options = { override = require("ui.icons").devicons }
options = require("core.utils").load_override(options, "kyazdani42/nvim-web-devicons")
devicons.setup(options)
end
end
return M return M

View File

@ -4,6 +4,10 @@ if not present then
return return
end end
vim.g.theme_switcher_loaded = true
require("base46").load_highlight "telescope"
local options = { local options = {
defaults = { defaults = {
vimgrep_arguments = { vimgrep_arguments = {

View File

@ -4,6 +4,9 @@ if not present then
return return
end end
require("base46").load_highlight "syntax"
require("base46").load_highlight "treesitter"
local options = { local options = {
ensure_installed = { ensure_installed = {
"lua", "lua",

View File

@ -4,6 +4,8 @@ if not present then
return return
end end
require("base46").load_highlight "whichkey"
local options = { local options = {
icons = { icons = {

View File

@ -1,9 +1,12 @@
vim.cmd "packadd packer.nvim"
local lazy_load = require "core.lazy_load"
local plugins = { local plugins = {
["nvim-lua/plenary.nvim"] = {}, ["nvim-lua/plenary.nvim"] = {},
["lewis6991/impatient.nvim"] = {},
["wbthomason/packer.nvim"] = {}, ["wbthomason/packer.nvim"] = {},
["NvChad/extensions"] = {}, ["NvChad/extensions"] = { module = "nvchad", cmd = "Telescope" },
["NvChad/base46"] = { ["NvChad/base46"] = {
after = "plenary.nvim", after = "plenary.nvim",
@ -24,43 +27,40 @@ local plugins = {
}, },
["kyazdani42/nvim-web-devicons"] = { ["kyazdani42/nvim-web-devicons"] = {
after = "base46", module = "nvim-web-devicons",
config = function() config = function()
require "plugins.configs.icons" require("plugins.configs.others").devicons()
end,
},
["SmiteshP/nvim-gps"] = {
event = "CursorMoved",
config = function()
require "plugins.configs.gps"
end, end,
}, },
["akinsho/bufferline.nvim"] = { ["akinsho/bufferline.nvim"] = {
tag = "v2.*", tag = "v2.*",
after = "nvim-web-devicons", opt = true,
setup = lazy_load.bufferline(),
config = function() config = function()
require "plugins.configs.bufferline" require "plugins.configs.bufferline"
end, end,
}, },
["lukas-reineke/indent-blankline.nvim"] = { ["lukas-reineke/indent-blankline.nvim"] = {
event = "BufRead", opt = true,
config = function() config = function()
require("plugins.configs.others").blankline() require("plugins.configs.others").blankline()
end, end,
}, },
["NvChad/nvim-colorizer.lua"] = { ["NvChad/nvim-colorizer.lua"] = {
event = "BufRead", opt = true,
setup = lazy_load.colorizer(),
config = function() config = function()
require("plugins.configs.others").colorizer() require("plugins.configs.others").colorizer()
end, end,
}, },
["nvim-treesitter/nvim-treesitter"] = { ["nvim-treesitter/nvim-treesitter"] = {
event = { "BufRead", "BufNewFile" }, module = "nvim-treesitter",
cmd = { "TSInstall", "TSUninstall" },
setup = lazy_load.treesitter(),
run = ":TSUpdate", run = ":TSUpdate",
config = function() config = function()
require "plugins.configs.treesitter" require "plugins.configs.treesitter"
@ -70,25 +70,17 @@ local plugins = {
-- git stuff -- git stuff
["lewis6991/gitsigns.nvim"] = { ["lewis6991/gitsigns.nvim"] = {
opt = true, opt = true,
setup = lazy_load.gitsigns(),
config = function() config = function()
require("plugins.configs.others").gitsigns() require("plugins.configs.others").gitsigns()
end, end,
setup = function()
require("core.utils").packer_lazy_load "gitsigns.nvim"
end,
}, },
-- lsp stuff -- lsp stuff
["williamboman/nvim-lsp-installer"] = { ["williamboman/nvim-lsp-installer"] = {
opt = true, opt = true,
setup = function() setup = lazy_load.on_file_open(),
require("core.utils").packer_lazy_load "nvim-lsp-installer"
-- reload the current file so lsp actually starts for it
vim.defer_fn(function()
vim.cmd 'if &ft == "packer" | echo "" | else | silent! e %'
end, 0)
end,
}, },
["neovim/nvim-lspconfig"] = { ["neovim/nvim-lspconfig"] = {
@ -100,15 +92,6 @@ local plugins = {
end, end,
}, },
["ray-x/lsp_signature.nvim"] = {
after = "nvim-lspconfig",
config = function()
require("plugins.configs.others").signature()
end,
},
-- load luasnips + cmp related in insert mode only -- load luasnips + cmp related in insert mode only
["rafamadriz/friendly-snippets"] = { ["rafamadriz/friendly-snippets"] = {
@ -190,11 +173,9 @@ local plugins = {
end, end,
}, },
-- Only load whichkey after all the gui
["folke/which-key.nvim"] = { ["folke/which-key.nvim"] = {
opt = true, module = "which-key",
setup = function()
require("core.utils").packer_lazy_load "which-key.nvim"
end,
config = function() config = function()
require "plugins.configs.whichkey" require "plugins.configs.whichkey"
end, end,

185
lua/ui/icons.lua Normal file
View File

@ -0,0 +1,185 @@
local M = {}
M.lspkind = {
Namespace = "",
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
Table = "",
Object = "",
Tag = "",
Array = "[]",
Boolean = "",
Number = "",
Null = "",
String = "",
Calendar = "",
Watch = "",
Package = "",
}
M.devicons = {
default_icon = {
icon = "",
name = "Default",
},
c = {
icon = "",
name = "c",
},
css = {
icon = "",
name = "css",
},
deb = {
icon = "",
name = "deb",
},
Dockerfile = {
icon = "",
name = "Dockerfile",
},
html = {
icon = "",
name = "html",
},
jpeg = {
icon = "",
name = "jpeg",
},
jpg = {
icon = "",
name = "jpg",
},
js = {
icon = "",
name = "js",
},
kt = {
icon = "󱈙",
name = "kt",
},
lock = {
icon = "",
name = "lock",
},
lua = {
icon = "",
name = "lua",
},
mp3 = {
icon = "",
name = "mp3",
},
mp4 = {
icon = "",
name = "mp4",
},
out = {
icon = "",
name = "out",
},
png = {
icon = "",
name = "png",
},
py = {
icon = "",
name = "py",
},
["robots.txt"] = {
icon = "",
name = "robots",
},
toml = {
icon = "",
name = "toml",
},
ts = {
icon = "",
name = "ts",
},
ttf = {
icon = "",
name = "TrueTypeFont",
},
rb = {
icon = "",
name = "rb",
},
rpm = {
icon = "",
name = "rpm",
},
vue = {
icon = "",
name = "vue",
},
woff = {
icon = "",
name = "WebOpenFontFormat",
},
woff2 = {
icon = "",
name = "WebOpenFontFormat2",
},
xz = {
icon = "",
name = "xz",
},
zip = {
icon = "",
name = "zip",
},
}
return M

54
lua/ui/lsp.lua Normal file
View File

@ -0,0 +1,54 @@
local function lspSymbol(name, icon)
local hl = "DiagnosticSign" .. name
vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl })
end
lspSymbol("Error", "")
lspSymbol("Info", "")
lspSymbol("Hint", "")
lspSymbol("Warn", "")
vim.diagnostic.config {
virtual_text = {
prefix = "",
},
signs = true,
underline = true,
update_in_insert = false,
}
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "single",
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "single",
})
-- suppress error messages from lang servers
vim.notify = function(msg, log_level)
if msg:match "exit code" then
return
end
if log_level == vim.log.levels.ERROR then
vim.api.nvim_err_writeln(msg)
else
vim.api.nvim_echo({ { msg } }, true, {})
end
end
-- Borders for LspInfo winodw
local win = require "lspconfig.ui.windows"
local _default_opts = win.default_opts
win.default_opts = function(options)
local opts = _default_opts(options)
opts.border = "single"
return opts
end
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "single",
silent = true,
focusable = false,
close_events = { "InsertCharPre", "CursorMoved" },
})

View File

@ -64,36 +64,34 @@ M.mode = function()
return current_mode .. mode_sep1 .. "%#ST_EmptySpace#" .. sep_r return current_mode .. mode_sep1 .. "%#ST_EmptySpace#" .. sep_r
end end
M.fileInfo = function() M.fileicon = function()
local icon = "" local icon = ""
local filename = fn.fnamemodify(fn.expand "%:t", ":r") local filename = fn.fnamemodify(fn.expand "%:t", ":r")
local extension = fn.expand "%:e" local extension = fn.expand "%:e"
if filename ~= "" then
local devicons_present, devicons = pcall(require, "nvim-web-devicons")
if devicons_present then
local ft_icon = devicons.get_icon(filename, extension)
icon = (ft_icon ~= nil and " " .. ft_icon) or ""
end
end
return "%#St_file_info#" .. icon
end
M.filename = function()
local filename = fn.fnamemodify(fn.expand "%:t", ":r")
if filename == "" then if filename == "" then
icon = icon .. "  Empty " filename = "Empty "
else else
filename = " " .. filename .. " " filename = " " .. filename .. " "
end end
local devicons_present, devicons = pcall(require, "nvim-web-devicons") return "%#St_file_info#" .. filename .. "%#St_file_sep#" .. sep_r
if not devicons_present then
return " "
end
local ft_icon = devicons.get_icon(filename, extension)
icon = (ft_icon ~= nil and " " .. ft_icon) or icon
return "%#St_file_info#" .. icon .. filename .. "%#St_file_sep#" .. sep_r
end
M.gps = function()
if vim.o.columns < 140 or not package.loaded["nvim-gps"] then
return ""
end
local gps = require "nvim-gps"
return (gps.is_available() and gps.get_location()) or ""
end end
M.git = function() M.git = function()
@ -189,12 +187,12 @@ end
M.run = function() M.run = function()
return table.concat { return table.concat {
M.mode(), M.mode(),
M.fileInfo(), M.fileicon(),
M.filename(),
M.git(), M.git(),
"%=", "%=",
M.LSP_progress(), M.LSP_progress(),
M.gps(),
"%=", "%=",
M.LSP_Diagnostics(), M.LSP_Diagnostics(),