GithubHelp home page GithubHelp logo

Indentation about snippets.nvim HOT 6 CLOSED

norcalli avatar norcalli commented on August 21, 2024
Indentation

from snippets.nvim.

Comments (6)

Shougo avatar Shougo commented on August 21, 2024

I think the example is needed.

from snippets.nvim.

tjdevries avatar tjdevries commented on August 21, 2024

Ah, I see. It doesn't actually require people to pass in the line number, as it is set to a v variable...

I was thinking that when expanding something and encountering \n character, you could insert the first line of the text, then call indentexpr to see what the indent of the next line would be.

I don't know if I have a good example, but basically I have an it expansion for lua to add it('$1', function()\n$0\nend) but the new lines don't indent to the right places (but they do when I hit enter)

from snippets.nvim.

Shougo avatar Shougo commented on August 21, 2024

I get it.
I think tab character conversion is better like other snippet plugins.

it('$1', function()\n\t$0\nend)

Note: neosnippet implements the auto indentation feature by indent plugins.
But some indentation plugins are broken(PHP, python, etc...).

from snippets.nvim.

clason avatar clason commented on August 21, 2024

From Gitter (copying here so it's preserved and more visible/searchable): you can now do

local match_indentation = require'snippets.utils'.match_indentation

and then apply it to a snippet like so

["for"] = match_indentation "for ${1:i} = 0, $2 do\n  $0\nend",

from snippets.nvim.

norcalli avatar norcalli commented on August 21, 2024

What he said.

It's also available in require'snippets'.u as an alias for "snippets.utils"

from snippets.nvim.

norcalli avatar norcalli commented on August 21, 2024

It also includes a general utility in case you don't like the one I made for prefixing new lines.

from snippets.nvim.

Related Issues (20)

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.