4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

lualine.nvimでステータスラインをカスタマイズするときのTips

Posted at

neovimやvimを豪華に彩る中でおそらく必須となるであろうステータスライン系プラグインの紹介記事です。

現在公開されているプラグインは様々な種類がありますが、luaで書かれた中ではおそらくlualine.nvimがデファクトです。

導入後
2023-03-17 13.17のイメージ.jpg

筆者のコード

READMEが非常に丁寧に書かれているので、ステータスラインの位置を指定し、lualineに同梱されているコンポーネントを設定するのが定石ですが、筆者はlualine.nvimのexamplesディレクトリにあるevil_lualine.luaをカスタマイズしています。

改良すべき点
Lspを表示するコンポーネントです。null-lsなどのフォーマット系プラグインを使用している場合はclient.name ~= "null-ls" thenとif文で除外するのがベターです。

ins_right {
      -- Lsp server name .
      function()
        local msg = "No Active"
        local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
        local clients = vim.lsp.get_active_clients()
        if next(clients) == nil then
          return msg
        end
        for _, client in ipairs(clients) do
          local filetypes = client.config.filetypes
          if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 and client.name ~= "null-ls" then
            return client.name
          end
        end
        return msg
      end,
      icon = " LSP:",
      color = { fg = colors.orange },
    }

結論

lualine.nvimは比較的癖のないプラグインで扱いやすいです。皆さんもぜひステータスラインライフを送りましょう!

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?