Code Monkey home page Code Monkey logo

gomodifytags's Introduction

gomodifytags

Caution

This plug-in is still very much in alpha phase, use at your own risk.

Pre-requisites

Installation

  • install using your favorite plugin manager (lazy in this example)
  {
    'simondrake/gomodifytags',
    dependencies = { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' },
  }

Set-up

Require and call the setup function, with optional configuration (see below) - require('gomodifytags').setup().

Configuration

By passing through an optional table into the setup() function, you can set defaults that can be overridden on a per-invocation basis. For example, to change the transformation to snakecase you would do the following:

require('gomodifytags').setup({transformation = "snakecase"})`

Or directly with the lazy plug-in manager:

  {
    'simondrake/gomodifytags',
    dependencies = { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' },
    opts = {
      transformation = "snakecase",
      skip_unexported = true,
      override = true,
      options = { "json=omitempty" }
    },
  }

The default configuration for this plug-in is below:

M.config = {
  transformation = "camelcase",
  skip_unexported = true,
  override = true,
  sort = false,
  options = {},
  parse = { enabled = false, seperator = "--" }
}

Running

GoAddTags

GoAddTags can be used, with optional overrides, by requiring and calling the GoAddTags function:

:lua require('gomodifytags').GoAddTags("json,yaml", {transformation = "snakecase", skip_unexported = false})

GoRemoveTags

GoRemoveTags can be used by requiring and calling the GoRemoveTags function:

:lua require('gomodifytags').GoRemoveTags("json,yaml")

Creating a command

Because of how vim.api.nvim_create_user_command works, it is not possible to pass through a table and args is a string parameter. If you would still like to use a command, this is very experimental and may have some edge cases.

If you would still like to try it out, you will need to set an additional configuration - parse. In most cases seperator can be kept as the default (--) but it is added as a configuration option in case you need to amend it.

require('gomodifytags').setup({transformation = "camelcase", parse = { enabled = true, seperator = "--" }})`

Or directly with the lazy plug-in manager:

  {
    'simondrake/gomodifytags',
    dependencies = { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' },
    opts = {
      transformation = "camelcase",
      skip_unexported = true,
      override = true,
      options = { "json=omitempty" },
      parse = { enabled = true, seperator = "--" },
    },
  }

You can use the following which will create a GoAddTags command:

vim.api.nvim_create_user_command('GoAddTags', function(opts) require('gomodifytags').GoAddTags(opts.fargs[1], opts.args) end, { nargs = "+" })

Which can be used with the following format, where <parse.seperator> is what is defined in the configuration (-- by default):

:GoAddTags "json" <parse.seperator> {transformation = "snakecase", skip_unexported = false}

gomodifytags's People

Contributors

simondrake avatar

Stargazers

skanehira avatar  avatar

Watchers

 avatar

Forkers

bwafi

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.