Code Monkey home page Code Monkey logo

cellwidths.nvim's Introduction

cellwidths.nvim

Yet another setcellwidths() wrapper.

これは何?

関数 setcellwidths() の設定を簡単にするプラグインです。この関数は以下のようにして使います。

call setcellwidths([[0x2103, 0x2103, 2], [0x2160, 0x2169, 2]])

引数には [開始, 終了, 文字幅] という配列の配列を指定するのですが、いくつかの理由から直接指定するのが困難です。

  • 現在指定している値を後から参照出来ない。
  • 値の追加、削除は出来ず、全ての配列を毎回指定しないといけない。
  • 'listchars''fillchars' に指定した値と被っていると設定に失敗する。

このプラグインはこれらを解決します。

インストール

'packpath' 配下のディレクトリにクローンして下さい。

git clone https://github.com/delphinus/cellwidths.nvim \
  ~/.local/share/nvim/site/pack/foo/start/cellwidths.nvim

または、好きなプラグインマネージャーを使って下さい。

-- for packer.nvim
use {
  "delphinus/cellwidths.nvim",
  config = function()
    -- 'listchars' と 'fillchars' を事前に設定しておくのがお勧めです。
    -- vim.opt.listchars = { eol = "⏎" }
    -- vim.opt.fillchars = { eob = "‣" }
    require("cellwidths").setup {
      name = "default",
      -- name = "empty",          -- 空の設定です。
      -- name = "default",        -- vim-ambiwidth のデフォルトです。
      -- name = "cica",           -- vim-ambiwidth の Cica 用設定です。
      -- name = "sfmono_square",  -- SF Mono Square 用設定です。
    }
  end,
}

使い方

テンプレートを使う

予め定められた値を利用するにはテンプレート名を指定して呼び出して下さい。

require("cellwidths").setup { name = "default" }

オリジナルの設定を作りたい場合は以下のようにして下さい。fallback() 関数で呼ばれた内容がファイルに保存され、次回起動時からは高速に読み込まれます。

require("cellwidths").setup {
  name = "user/custom",
  ---@param cw cellwidths
  fallback = function(cw)
    -- 特定のテンプレートから追加・削除を行いたい場合は最初に load() を呼んで下さい。
    -- cw.load "default"

    -- 好きな設定を追加します。以下のどの書式でも構いません。
    cw.add(0x2103, 2)
    cw.add { 0x2160, 0x2169, 2 }
    cw.add {
      { 0x2170, 0x2179, 2 },
      { 0x2190, 0x2193, 2 },
    }

    -- 削除も出来ます。設定に存在しないコードポイントを指定してもエラーになりません。
    cw.delete(0x2103)
    cw.delete { 0x2104, 0x2105, 0x2106 }
  end,
}

コマンドを使う

Neovim を起動中にオンデマンドで設定を変更することも可能です。

" 「℃」を全角で扱います。
:CellWidthsAdd 0x2103, 2
" 設定を削除します。
:CellWidthsDelete 0x2103
" テンプレートを読み込みます。
:CellWidthsLoad default
" (現在利用中の)テンプレートを削除します。
:CellWidthsRemove

より詳しい使い方はヘルプを見て下さい。

リンク

cellwidths.nvim's People

Contributors

delphinus avatar github-actions[bot] avatar gw31415 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.