Giter Club home page Giter Club logo

nvim-lua-guide-zh's Issues

关于neovim lua api处理syntax指令

想知道lua是否有相关api或者方式来处理syntax相关的指令,比如

syntax keyword jack_keyword_class class

这样的syntax语法定义是否有lua的方式?🧐
谢谢

请问neovim处理字符宽度有什么技巧吗

最近想写一个翻译插件,格式化排版,计算窗口wrap后的高度,用的这样一个函数

local function get_height(bufnr, winid)
    if not vim.wo[winid].wrap then
        return vim.api.nvim_buf_line_count(bufnr)
    end

    local width = vim.api.nvim_win_get_width(winid)


    local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
    local height = 0
    for i = 1, #lines do
        height = height + math.max(1, (math.ceil(vim.fn.strdisplaywidth(lines[i]) / width)))
    end
    return height
end

计算结果总是不符合预期, 使用vim.fn.strdisplaywidth和vim.fn.strwidth` 结果相同

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.