diff --git a/README.md b/README.md index d11af3c..bc29071 100644 --- a/README.md +++ b/README.md @@ -107,3 +107,4 @@ formatters installed here are used via `conform.nvim`. - ollama integration - +- diff --git a/lua/weeheavy/plugins/lualine.lua b/lua/weeheavy/plugins/lualine.lua index 94726ae..20c99cf 100644 --- a/lua/weeheavy/plugins/lualine.lua +++ b/lua/weeheavy/plugins/lualine.lua @@ -1,8 +1,32 @@ -- status line like vim-airline + +-- Display attached LSP client +local function lsp_clients() + local clients = vim.lsp.get_active_clients() + local client_names = {} + local buf_ft = vim.api.nvim_buf_get_option(0, "filetype") + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + return client.name + end + end + if next(client_names) == nil then + return "no LS" + end + --return "[" .. table.concat(client_names, ", ") .. "]" +end + +-- hide content on narrow windows +local function hide_in_width() + return vim.fn.winwidth(0) > 80 +end + return { "nvim-lualine/lualine.nvim", lazy = true, event = { "BufReadPre", "BufNewFile" }, + opts = { options = { icons_enabled = true, @@ -13,5 +37,14 @@ return { --section_separators = { left = '', right = '' }, section_separators = { left = "", right = "" }, }, + sections = { + lualine_x = { + -- specify full list of elements when adding custom things + { "encoding" }, + { "fileformat" }, + { "filetype" }, + { lsp_clients, cond = hide_in_width }, + }, + }, }, }