Coder Social home page Coder Social logo

lsp-fastaction.nvim's Introduction

Lsp-fastaction

A small plugin to map a lsp code action to 1 key and sort the code action

Install

Plug {'windwp/lsp-fastaction.nvim'}
--- sample for dart with flutter
require('lsp-fastaction').setup({
    hide_cursor = true,
    action_data = {
      --- action for filetype dart
        ['dart'] = {
            -- pattern is a lua regex with lower case
            { pattern = 'import library', key = 'i', order = 1 },
            { pattern = 'wrap with widget', key = 'w', order = 2 },
            { pattern = 'wrap with column', key = 'c', order = 3 },
            { pattern = 'wrap with row', key = 'r', order = 3 },
            { pattern = 'wrap with sizedbox', key = 's', order = 3 },
            { pattern = 'wrap with container', key = 'C', order = 4 },
            { pattern = 'wrap with center', key = 'E', order = 4 },
            { pattern = 'padding', key = 'P', order = 4 },
            { pattern = 'wrap with streambuilder', key = 'S', order = 5 },
            { pattern = 'remove', key = 'R', order = 5 },

            --range code action
            { pattern = "surround with %'if'", key = 'i', order = 2 },
            { pattern = 'try%-catch', key = 't', order = 2 },
            { pattern = 'for%-in', key = 'f', order = 2 },
            { pattern = 'setstate', key = 's', order = 2 },
        },
        ['typescript'] = {
            { pattern = 'to existing import declaration', key = 'a', order = 2 },
            { pattern = 'from module', key = 'i', order = 1 },
        },
    },
})

--- add this to your mapping on lsp
    vim.api.nvim_buf_set_keymap(
        bufnr,
        'n',
        '<leader>a',
        '<cmd>lua require("lsp-fastaction").code_action()<CR>'
    )
    vim.api.nvim_buf_set_keymap(
        bufnr,
        'v',
        '<leader>a',
        "<esc><cmd>lua require('lsp-fastaction').range_code_action()<CR>",
    )

๐ŸŒŸ Credits

Most of code I copy from telescope and octo @pwntester ๐Ÿ˜ƒ

lsp-fastaction.nvim's People

Contributors

akinsho avatar windwp 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

Watchers

 avatar  avatar

lsp-fastaction.nvim's Issues

Unusable when too many code actions

I get the following error when I open lsp-fastaction floating window when there are larger number of code actions. I am coding in flutter and large number of code-actions is pretty common.

E5108: Error executing lua ...cker/opt/lsp-fastaction.nvim/lua/lsp-fastaction/init.lua:111: Expected lua string                                                         
stack traceback:
        [C]: in function 'nvim_buf_set_keymap'
        ...cker/opt/lsp-fastaction.nvim/lua/lsp-fastaction/init.lua:111: in function 'show_menu'
        ...cker/opt/lsp-fastaction.nvim/lua/lsp-fastaction/init.lua:149: in function 'request_code_action'
        ...cker/opt/lsp-fastaction.nvim/lua/lsp-fastaction/init.lua:158: in function 'code_action'
        [string ":lua"]:1: in main chunk

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.