From 4f76a8550fe8a70d75a487d12205885aa72ea49a Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Mon, 21 Sep 2026 18:25:43 -0500 Subject: add user@host marker to statusline in ssh and window title. move tabs options for sass into ftplugin. move ftplugin to after/ftplugin to load and override official ftplugins --- after/ftplugin/nix.lua | 4 ++++ after/ftplugin/sass.lua | 7 +++++++ after/ftplugin/scss.lua | 1 + ftplugin/nix.lua | 4 ---- lua/tjk/misc.lua | 29 +++++++++++++++-------------- 5 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 after/ftplugin/nix.lua create mode 100644 after/ftplugin/sass.lua create mode 120000 after/ftplugin/scss.lua delete mode 100644 ftplugin/nix.lua diff --git a/after/ftplugin/nix.lua b/after/ftplugin/nix.lua new file mode 100644 index 0000000..a1371c2 --- /dev/null +++ b/after/ftplugin/nix.lua @@ -0,0 +1,4 @@ +--vim.bo.expandtab = true +vim.bo.tabstop = 2 +vim.bo.shiftwidth = 2 +vim.bo.softtabstop = 2 diff --git a/after/ftplugin/sass.lua b/after/ftplugin/sass.lua new file mode 100644 index 0000000..049ac89 --- /dev/null +++ b/after/ftplugin/sass.lua @@ -0,0 +1,7 @@ +-- tabs instead of spaces +vim.opt_local.expandtab = false +--vim.opt_local.cinoptions = true +--vim.opt_local.preserveindent = true +vim.opt_local.softtabstop = 0 +vim.opt_local.shiftwidth = 4 +vim.opt_local.tabstop = 4 diff --git a/after/ftplugin/scss.lua b/after/ftplugin/scss.lua new file mode 120000 index 0000000..a593f83 --- /dev/null +++ b/after/ftplugin/scss.lua @@ -0,0 +1 @@ +sass.lua \ No newline at end of file diff --git a/ftplugin/nix.lua b/ftplugin/nix.lua deleted file mode 100644 index a1371c2..0000000 --- a/ftplugin/nix.lua +++ /dev/null @@ -1,4 +0,0 @@ ---vim.bo.expandtab = true -vim.bo.tabstop = 2 -vim.bo.shiftwidth = 2 -vim.bo.softtabstop = 2 diff --git a/lua/tjk/misc.lua b/lua/tjk/misc.lua index 14c5bd8..56ba209 100644 --- a/lua/tjk/misc.lua +++ b/lua/tjk/misc.lua @@ -1,21 +1,22 @@ --- Use tabs instead of spaces for certain filetypes -local tabs_instead_of_spaces_filetypes = { - "sass", - "scss", -} +local user_at_host = vim.uv.os_get_passwd().username .. "@" .. vim.uv.os_gethostname() -local tabs_instead_of_spaces = function(args) - local o = vim.opt_local - o.expandtab = false - --o.cinoptions = true - o.preserveindent = true - o.softtabstop = 0 - o.shiftwidth = 4 - o.tabstop = 4 +-- insert user@host into statusline if running in ssh session +if vim.env.SSH_CONNECTION ~= nil or vim.env.SSH_TTY ~= nil then + local ssh_status = "[" .. user_at_host .. "] " + vim.o.statusline = vim.o.statusline:gsub("%%f", ssh_status .. "%%f", 1) -- before filename end -vim.api.nvim_create_autocmd("FileType", { pattern = tabs_instead_of_spaces_filetypes, callback = tabs_instead_of_spaces }) +-- insert user@host into titlestring +-- builtin titlestring must be reconstructed +function _G.title_flags() + local f = (vim.bo.readonly and "=" or "") .. (vim.bo.modified and "+" or "") + if not vim.bo.modifiable then f = f .. "-" end + return f ~= "" and (" " .. f) or "" +end + +vim.o.titlestring = '%t%{v:lua.title_flags()} (' .. user_at_host .. ' %{expand("%:~:h")}%a) - Nvim' +-- vim.cmd [[ "" Extra functionality -- cgit v1.3.1