Giter Club home page Giter Club logo

textobj-diagnostic.nvim's Introduction

textobj-diagnostic.nvim

โš ๏ธ NO LONGER ACTIVELY DEVELOPED: This plugin is now archived; personally I have replaced it with this plugin.

This NeoVim plugin provides a standard Vim text object for NeoVim diagnostics (such as those produced by the LSP, null-ls, etc.). It enables the user to type commands like cig to jump to the next diagnostic, delete the highlighted text, and enter insert mode.

Demo

Demo Video

Installation

Requires NeoVim 0.7+.

This is a standard NeoVim plugin.

Example for packer.nvim:

packer.startup(function(use)

    ...

    use({
        "andrewferrier/textobj-diagnostic.nvim",
        config = function()
            require("textobj-diagnostic").setup()
        end,
    })

    ...

end)

Mappings

By default, the following keymappings are defined in the operator-pending and visual modes (as well as other functions not mapped to keys by default):

keymapping function purpose
ig require('textobj-diagnostic').next_diag_inclusive() finds the diagnostic under or after the cursor (including any diagnostic the cursor is sitting on)
]g require('textobj-diagnostic').next_diag() finds the diagnostic after the cursor (excluding any diagnostic the cursor is sitting on)
[g require('textobj-diagnostic').prev_diag() finds the diagnostic before the cursor (excluding any diagnostic the cursor is sitting on)
No mapping by default require('textobj-diagnostic').nearest_diag() find the diagnostic nearest to the cursor, under, before, or after, taking into account both vertical and horizontal distance

Examples of use:

  • cig - jump to the next diagnostic (or the one under the cursor) and CHANGE it (delete the text and enter insert mode)

  • v[g - visually select the previous diagnostic

  • d]g - delete the next diagnostic text (excluding any diagnostic under the cursor)

If you don't like the default keymappings in the table above, or want to limit which diagnostics are selected by them, you can disable the default keymappings:

use({
    "andrewferrier/textobj-diagnostic.nvim",
    config = function()
        require("textobj-diagnostic").setup({create_default_keymaps = false})
    end,
})

Then, you can map your own. (note: the previous restrictions around using VimL here rather than Lua have been resolved). For example, to create a keymapping for the diagnostic item under the cursor (or the next one) of id:

vim.keymap.set({ "x", "o" }, "id", function()
    require("textobj-diagnostic").next_diag_inclusive()
end, { silent = true })

To map to the next diagnostic item after the cursor (excluding where the cursor is):

vim.keymap.set({ "x", "o" }, "]d", function()
    require("textobj-diagnostic").next_diag()
end, { silent = true })

Any key/value you pass into the first parameter of any of the functions is passed to vim.diagnostic.get, which means it can be used to control the namespace or severity of the errors being selected. For example:

vim.keymap.set({ "x", "o" }, "ig", function()
    require("textobj-diagnostic").next_diag_inclusive({
        severity = {
            min = vim.diagnostic.severity.WARN,
            max = vim.diagnostic.severity.ERROR,
        },
    })
end, { silent = true })

textobj-diagnostic.nvim's People

Contributors

andrewferrier avatar smoka7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

textobj-diagnostic.nvim's Issues

Tracking demo resources

Hi, great plugin, very useful:)
One nitpick: saving gifs/videos in git means that they will be downloaded together with the code when users install the plugin, thereby slowing down the installation and taking extra space. A way around that is to upload the gif to an external source (eg, to an issue) and link to the issue in the readme.
I'm open to doing it if you approve.

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.