kristijanhusak / neovim-config

Neovim configuration
259 stars 39 forks source link

suggestion: use relative path for statusline path #10

Open matu3ba opened 1 year ago

matu3ba commented 1 year ago

Trying to yank a few lines for the search count (I hate it being a separate wasted line), I got to your config. I do also like your lsp progress and gitsigns solution, though I think I need to install something for this to work. it just works (for me).

add_cmd('Frel', function() vim.fn.setreg('+', plenary.path:new(vim.api.nvim_buf_get_name(0)):make_relative()) end, {}) -- copy relative path plenary.path handles gracefully uris, so oil:// etc path just work and dont need extra handling..

if you prefer checking against cwd (relative path resolving does this automatically and falls back to absolute one if not within cwd) you could use uv.cwd() like you use it elsewhere. If you use alot harpoon, you might find a few handy things in my dotfiles.

This also makes several of your vim.fs.dirname superfluous. See also :h vim.fs

matu3ba commented 1 year ago

If you dont need the number of changes, then

local function get_fileinfo()
  if vim.bo.buftype == "" then
    if vim.bo.readonly == true then
      return "ro"
    end
    if vim.bo.modified then
      return "+"
    else
      return " "
    end
  end
end

is much simpler to handle.

matu3ba commented 1 year ago

my bad. This is needed to handle all relevant cases:

local function get_fileinfo()
  if vim.bo.buftype == "" then
    if vim.bo.readonly == true then
      return "ro"
    end
    if vim.bo.modified then
      return " +"
    else
      return "  "
    end
  elseif vim.bo.buftype == "acwrite" then
    return "ac"
  elseif vim.bo.buftype == "help" then
    return "he"
  elseif vim.bo.buftype == "nofile" then
    return "nf"
  elseif vim.bo.buftype == "nowrite" then
    return "nw"
  elseif vim.bo.buftype == "quickfix" then
    return "qf"
  elseif vim.bo.buftype == "terminal" then
    return "te"
  elseif vim.bo.buftype == "prompt" then
    return "pr"
  else
    return "  "
  end
end