GithubHelp home page GithubHelp logo

organ1sm / cppassist.nvim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kohirus/cppassist.nvim

0.0 0.0 0.0 39 KB

A Neovim plugin that can do sometings like VAssistX.

C++ 6.00% C 0.41% Lua 89.53% Vim Script 4.06%

cppassist.nvim's Introduction

A Neovim plugin that can do sometings like VAssistX.

example-movie.mp4

Installation📦

use {
  'Kohirus/cppassist.nvim',
  opt = true,
  ft = { "h", "cpp", "hpp", "c", "cc", "cxx" },
  config = function()
    require("cppassist").setup()
  end,
}

Dependency💻

Now this plugin depends on fd instead of plenary.nvim. So please make sure the fd has been installed in your system.

Configuration🧱

Default configuration

require('cppassist').setup {
  -- For `SwitchSourceAndHeader`, `ImplementInSource` and `ImplementOutOfClass` command
  switch_sh = {
    -- Search for target files in the following directories
    include_dirs = { ".", ".." },
    -- Exclude the following directories when searching for target files
    exclude_dirs = {},
    -- If you want other flags, see `man fd`
    -- -t: This option can be specified more than once to include multiple file types.
    -- -s: Perform a case-sensitive search.
    -- -L: Using this flag, symbolic links are also traversed.
    search_flags = "-tf -s -L",
    -- If the return type contains the following keywords, the value of the right side will be used in the return statement
    return_type = {
      int = "0",
      short = "0",
      long = "0",
      char = "0",
      double = "0.0",
      float = "0.0",
      bool = "false",
      pointer = "nullptr",
    }
  },
  -- For `GotoHeaderFile` command
  goto_header = {
    include_dirs = { ".", "..", "/usr/include", "/usr/local/include", "~" },
    exclude_dirs = {},
    search_flags = "-tf -s",
  },
}

Details📝

  • It uses regular expressions instead of LSP;
  • It can recognize underscores and asterisks in data types;
  • It can recognize the simple return type;
  • It can recognize multi-line function declarations;
  • It can recognize class templates;
  • It can recognize function default parameters and remove them;
  • It can recognize the following keywords: const,explicit, static, override, final, virtual, friend, = 0, = default, = delete, noexcept, constexpr;
  • It supports multiple functions at the same time in Visual mode;
  • It supports the custom return value of the basic data type;
  • If there are multiple matching at the same time, it will display the optional list;
  • Now, it Supports the jump of the header file;

In my opinion, the inline keyword should be defined in the source file and not in the header file, because this keyword needs to be told to the compiler, not the user, so it is not implemented here

Usage🔨

Place the cursor on the line where the declaration is located, and press the shortcut key to generate the corresponding definition.

If a function is defined on more than one line, place the cursor on the starting line in the function definition!

If you want to jump to the specified header file, place the cursor on the #include line. If there are multiple matches at the same time, there will be a optional list for selection.

local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }

-- switch between source and header
map('n', '<A-o>', '<Cmd>SwitchSourceAndHeader<CR>', opts)
-- generate the function definition or static variable definition in source
map('n', '<leader>cf', '<Cmd>ImplementInSource<CR>', opts)
-- generate the function definition or static variable definition in source in visual mode
map('v', '<leader>cf', '<Cmd>lua require("cppassist").ImplementInSourceInVisualMode<CR>', opts)
-- generate the function definition or static variable definition in header
map('n', '<leader>cv', '<Cmd>ImplementOutOfClass<CR>', opts)
-- goto the header file
map('n', '<leader>gh', '<Cmd>GotoHeaderFile<CR>', opts)

TODO🚀

  • switch between source and header
  • generate the function definition in source
  • generate the static variable in source
  • generate the Get()/Set() method for variable
  • generate the multi function definitions in the view mode
  • goto the header file

Special Thanks🙏

  • ouroboros.nvim: quickly switching between header and implementation files

Ideas💡

If you have a better idea, please tell me with email: [email protected]

cppassist.nvim's People

Contributors

kohirus avatar organ1sm 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.