|
1 | 1 | return { |
2 | 2 | "nvim-lualine/lualine.nvim", |
3 | | - event = "BufReadPost", |
4 | | - opts = { |
5 | | - extensions = { "fzf", "lazy", "mason", "quickfix", "neo-tree" }, |
6 | | - options = { |
7 | | - disabled_filetypes = { "neo-tree", "snacks_dashboard", "Outline" }, |
8 | | - }, |
9 | | - sections = { |
10 | | - lualine_a = {}, -- hide mode |
11 | | - lualine_b = { |
12 | | - "branch", |
13 | | - "diff", |
14 | | - "diagnostics", |
15 | | - }, |
16 | | - lualine_c = { |
17 | | - { |
18 | | - "filename", |
19 | | - file_status = true, -- Displays file status (readonly status, modified status) |
20 | | - newfile_status = true, -- Display new file status (new file means no write after created) |
21 | | - path = 3, -- 0: Just the filename |
22 | | - -- 1: Relative path |
23 | | - -- 2: Absolute path |
24 | | - -- 3: Absolute path, with tilde as the home directory |
25 | | - -- 4: Filename and parent dir, with tilde as the home directory |
26 | | - }, |
27 | | - }, |
28 | | - lualine_x = { "filetype" }, |
29 | | - lualine_y = { "progress" }, |
30 | | - lualine_z = { "mode" }, |
31 | | - }, |
32 | | - }, |
33 | | - config = function(_, opts) |
34 | | - -- Show info when recording a macro |
35 | | - local function is_macro_recording() |
36 | | - local reg = vim.fn.reg_recording() |
37 | | - if reg == "" then |
| 3 | + dependencies = { "nvim-tree/nvim-web-devicons" }, |
| 4 | + event = "VeryLazy", |
| 5 | + config = function() |
| 6 | + -- Custom Lualine component to show attached language server |
| 7 | + local clients_lsp = function() |
| 8 | + local clients = vim.lsp.get_clients() |
| 9 | + if next(clients) == nil then |
38 | 10 | return "" |
39 | 11 | end |
40 | | - return " " .. reg |
41 | | - end |
42 | | - |
43 | | - table.insert(opts.sections.lualine_x, 1, { |
44 | | - is_macro_recording, |
45 | | - color = { fg = "#333333", bg = "#ff6666" }, |
46 | | - separator = { left = "", right = "" }, |
47 | | - cond = function() |
48 | | - return is_macro_recording() ~= "" |
49 | | - end, |
50 | | - }) |
51 | 12 |
|
52 | | - -- Don't display encoding if encoding is UTF-8 |
53 | | - local function encoding() |
54 | | - local ret, _ = (vim.bo.fenc or vim.go.enc):gsub("^utf%-8$", "") |
55 | | - return ret |
56 | | - end |
57 | | - |
58 | | - table.insert(opts.sections.lualine_x, 1, { |
59 | | - encoding, |
60 | | - cond = function() |
61 | | - return encoding() ~= "" |
62 | | - end, |
63 | | - }) |
64 | | - |
65 | | - -- Don't display fileformat if fileformat is unix |
66 | | - local function fileformat() |
67 | | - local ret, _ = vim.bo.fileformat:gsub("^unix$", "") |
68 | | - return ret |
69 | | - end |
70 | | - |
71 | | - table.insert(opts.sections.lualine_x, 1, { |
72 | | - fileformat, |
73 | | - cond = function() |
74 | | - return fileformat() ~= "" |
75 | | - end, |
76 | | - }) |
77 | | - |
78 | | - local function wordCount() |
79 | | - local wc = vim.fn.wordcount() |
80 | | - if wc == nil then |
81 | | - return "" |
82 | | - end |
83 | | - if wc["visual_words"] then -- text is selected in visual mode |
84 | | - return wc["visual_words"] .. " Words/" .. wc["visual_chars"] .. " Chars (Vis)" |
85 | | - else -- all of the document |
86 | | - return wc["words"] .. " Words" |
| 13 | + local c = {} |
| 14 | + for _, client in pairs(clients) do |
| 15 | + table.insert(c, client.name) |
87 | 16 | end |
| 17 | + return " " .. table.concat(c, "|") |
88 | 18 | end |
89 | 19 |
|
90 | | - table.insert(opts.sections.lualine_y, 1, { |
91 | | - wordCount, |
92 | | - cond = function() |
93 | | - local ft = vim.bo.filetype |
94 | | - local count = { |
95 | | - latex = true, |
96 | | - tex = true, |
97 | | - text = true, |
98 | | - markdown = true, |
99 | | - vimwiki = true, |
100 | | - } |
101 | | - return count[ft] ~= nil |
102 | | - end, |
| 20 | + require("lualine").setup({ |
| 21 | + options = { |
| 22 | + component_separators = "", |
| 23 | + section_separators = { left = "", right = "" }, |
| 24 | + disabled_filetypes = { "alpha", "Outline", "snacks_dashboard" }, |
| 25 | + }, |
| 26 | + sections = { |
| 27 | + lualine_a = { |
| 28 | + { "mode", icon = "" }, |
| 29 | + }, |
| 30 | + lualine_b = { |
| 31 | + { |
| 32 | + "filetype", |
| 33 | + icon_only = true, |
| 34 | + padding = { left = 1, right = 0 }, |
| 35 | + }, |
| 36 | + "filename", |
| 37 | + }, |
| 38 | + lualine_c = { |
| 39 | + { |
| 40 | + "branch", |
| 41 | + icon = "", |
| 42 | + }, |
| 43 | + { |
| 44 | + "diff", |
| 45 | + symbols = { added = " ", modified = " ", removed = " " }, |
| 46 | + colored = true, |
| 47 | + }, |
| 48 | + }, |
| 49 | + lualine_x = { |
| 50 | + { |
| 51 | + "diagnostics", |
| 52 | + symbols = { error = " ", warn = " ", info = " ", hint = " " }, |
| 53 | + update_in_insert = true, |
| 54 | + }, |
| 55 | + }, |
| 56 | + lualine_y = { clients_lsp }, |
| 57 | + lualine_z = { |
| 58 | + { "location", icon = "" }, |
| 59 | + }, |
| 60 | + }, |
| 61 | + inactive_sections = { |
| 62 | + lualine_a = { "filename" }, |
| 63 | + lualine_b = {}, |
| 64 | + lualine_c = {}, |
| 65 | + lualine_x = {}, |
| 66 | + lualine_y = {}, |
| 67 | + lualine_z = { "location" }, |
| 68 | + }, |
| 69 | + extensions = { "toggleterm", "trouble" }, |
103 | 70 | }) |
104 | | - |
105 | | - require("lualine").setup(opts) |
| 71 | + vim.api.nvim_set_hl(0, "lualine_a_visual", { fg = "#000000", bg = "#dc4c44", bold = true }) |
| 72 | + vim.api.nvim_set_hl(0, "lualine_a_replace", { fg = "#000000", bg = "#dc4c44", bold = true }) |
| 73 | + vim.api.nvim_set_hl(0, "lualine_a_command", { fg = "#000000", bg = "#f9e2af", bold = true }) |
| 74 | + vim.api.nvim_set_hl(0, "lualine_a_insert", { fg = "#000000", bg = "#a6e3a1", bold = true }) |
106 | 75 | end, |
107 | 76 | } |
0 commit comments