diff options
| author | Thomas Schmucker <ts@its1.de> | 2026-02-24 22:47:20 +0100 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2026-02-24 22:47:20 +0100 |
| commit | 34a3a3ae4d5d42f01e60525b0ea5bb43d36f7e91 (patch) | |
| tree | 2d6248aae1a372c83900e87c3ed81f7260afa73f /nvim/lua/config | |
| parent | dfd580c27540bea3e00cd63fa81f63e1ac350362 (diff) | |
| download | dotfiles-34a3a3ae4d5d42f01e60525b0ea5bb43d36f7e91.tar.gz dotfiles-34a3a3ae4d5d42f01e60525b0ea5bb43d36f7e91.tar.bz2 dotfiles-34a3a3ae4d5d42f01e60525b0ea5bb43d36f7e91.zip | |
neovim: statusline zeigt nun auch den Copilot-Status an
Diffstat (limited to 'nvim/lua/config')
| -rw-r--r-- | nvim/lua/config/statusline.lua | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/nvim/lua/config/statusline.lua b/nvim/lua/config/statusline.lua index fb89a66..7c61956 100644 --- a/nvim/lua/config/statusline.lua +++ b/nvim/lua/config/statusline.lua | |||
| @@ -63,10 +63,14 @@ vim.api.nvim_create_autocmd( | |||
| 63 | -- Statusline-Sektionen (reine Darstellung, keine IO) | 63 | -- Statusline-Sektionen (reine Darstellung, keine IO) |
| 64 | ---------------------------------------------------------------------- | 64 | ---------------------------------------------------------------------- |
| 65 | 65 | ||
| 66 | -- Git-Branch (buffer-lokal, gecached, kein redraw-spam) | ||
| 67 | |||
| 66 | local function git() | 68 | local function git() |
| 67 | return vim.b.git_branch or "" | 69 | return vim.b.git_branch or "" |
| 68 | end | 70 | end |
| 69 | 71 | ||
| 72 | -- Git-Diff (buffer-lokal, kein redraw-spam) | ||
| 73 | |||
| 70 | local function git_diff() | 74 | local function git_diff() |
| 71 | local gsd = vim.b.gitsigns_status_dict | 75 | local gsd = vim.b.gitsigns_status_dict |
| 72 | if not gsd then return "" end | 76 | if not gsd then return "" end |
| @@ -83,6 +87,10 @@ local function git_diff() | |||
| 83 | return "" | 87 | return "" |
| 84 | end | 88 | end |
| 85 | 89 | ||
| 90 | ---------------------------------------------------------------------- | ||
| 91 | -- Dateiname mit Modifikationsstatus | ||
| 92 | ---------------------------------------------------------------------- | ||
| 93 | |||
| 86 | local function filename() | 94 | local function filename() |
| 87 | local name = vim.fn.expand("%:t") | 95 | local name = vim.fn.expand("%:t") |
| 88 | if name == "" then | 96 | if name == "" then |
| @@ -96,6 +104,10 @@ local function filename() | |||
| 96 | return " " .. name .. " " | 104 | return " " .. name .. " " |
| 97 | end | 105 | end |
| 98 | 106 | ||
| 107 | ------------------------------------------------------------------------ | ||
| 108 | -- Treesitter-Aktivität (buffer-lokal, kein redraw-spam) | ||
| 109 | ------------------------------------------------------------------------ | ||
| 110 | |||
| 99 | local function treesitter() | 111 | local function treesitter() |
| 100 | local ok = vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()] | 112 | local ok = vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()] |
| 101 | if ok then | 113 | if ok then |
| @@ -104,6 +116,10 @@ local function treesitter() | |||
| 104 | return "" | 116 | return "" |
| 105 | end | 117 | end |
| 106 | 118 | ||
| 119 | ------------------------------------------------------------------------ | ||
| 120 | -- Diagnostik-Counts (buffer-lokal, kein redraw-spam) | ||
| 121 | ------------------------------------------------------------------------ | ||
| 122 | |||
| 107 | local function diagnostics() | 123 | local function diagnostics() |
| 108 | local counts = { | 124 | local counts = { |
| 109 | error = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }), | 125 | error = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }), |
| @@ -126,16 +142,48 @@ local function diagnostics() | |||
| 126 | return "" | 142 | return "" |
| 127 | end | 143 | end |
| 128 | 144 | ||
| 145 | ------------------------------------------------------------------------ | ||
| 146 | -- Filetype & Encoding (buffer-lokal, kein redraw-spam) | ||
| 147 | ------------------------------------------------------------------------ | ||
| 148 | |||
| 129 | local function fileinfo() | 149 | local function fileinfo() |
| 130 | local ft = vim.bo.filetype ~= "" and vim.bo.filetype or "none" | 150 | local ft = vim.bo.filetype ~= "" and vim.bo.filetype or "none" |
| 131 | local enc = vim.bo.fileencoding ~= "" and vim.bo.fileencoding or vim.o.encoding | 151 | local enc = vim.bo.fileencoding ~= "" and vim.bo.fileencoding or vim.o.encoding |
| 132 | return string.format(" %s %s ", ft, enc) | 152 | return string.format(" %s %s ", ft, enc) |
| 133 | end | 153 | end |
| 134 | 154 | ||
| 155 | ------------------------------------------------------------------------ | ||
| 156 | -- Cursor-Position (kein redraw-spam) | ||
| 157 | ------------------------------------------------------------------------ | ||
| 158 | |||
| 135 | local function position() | 159 | local function position() |
| 136 | return string.format(" %d:%d ", vim.fn.line("."), vim.fn.col(".")) | 160 | return string.format(" %d:%d ", vim.fn.line("."), vim.fn.col(".")) |
| 137 | end | 161 | end |
| 138 | 162 | ||
| 163 | ------------------------------------------------------------------------- | ||
| 164 | -- Copilot-Status (buffer-lokal, kein redraw-spam) | ||
| 165 | ------------------------------------------------------------------------- | ||
| 166 | |||
| 167 | local function copilot() | ||
| 168 | if vim.fn.exists("*copilot#Enabled") == 0 then | ||
| 169 | return "" | ||
| 170 | end | ||
| 171 | |||
| 172 | if vim.fn["copilot#Enabled"]() == 0 then | ||
| 173 | return " OFF " | ||
| 174 | end | ||
| 175 | |||
| 176 | if vim.b.copilot_suggestion and vim.b.copilot_suggestion.is_visible then | ||
| 177 | return " SUG " | ||
| 178 | end | ||
| 179 | |||
| 180 | if vim.b.copilot_suggestion_auto_trigger == false then | ||
| 181 | return " MAN " | ||
| 182 | end | ||
| 183 | |||
| 184 | return " ON " | ||
| 185 | end | ||
| 186 | |||
| 139 | ---------------------------------------------------------------------- | 187 | ---------------------------------------------------------------------- |
| 140 | -- Öffentliche Statusline-Funktion | 188 | -- Öffentliche Statusline-Funktion |
| 141 | ---------------------------------------------------------------------- | 189 | ---------------------------------------------------------------------- |
| @@ -153,9 +201,9 @@ function M.statusline() | |||
| 153 | "%=", | 201 | "%=", |
| 154 | 202 | ||
| 155 | -- RIGHT: Feedback & Meta | 203 | -- RIGHT: Feedback & Meta |
| 204 | copilot(), | ||
| 156 | diagnostics(), | 205 | diagnostics(), |
| 157 | treesitter(), | 206 | treesitter(), |
| 158 | "%#StatusLineNC#", | ||
| 159 | fileinfo(), | 207 | fileinfo(), |
| 160 | " %p%% ", | 208 | " %p%% ", |
| 161 | position(), | 209 | position(), |
