GithubHelp home page GithubHelp logo

nmac427 / guess-indent.nvim Goto Github PK

View Code? Open in Web Editor NEW
347.0 2.0 7.0 59 KB

Automatic indentation style detection for Neovim

License: MIT License

Lua 95.98% Makefile 3.32% Vim Script 0.70%
vim neovim indentation nvim autoindent nvim-plugin lua

guess-indent.nvim's Introduction

:GuessIndent

MIT License Tests

Blazing fast indentation style detection for Neovim written in Lua. The goal of this plugin is to automatically detect the indentation style used in a buffer and updating the buffer options accordingly. This mimics the "Guess Indentation Settings From Buffer" function built into Sublime Text.

How it works

Whenever you open a new buffer, guess-indent looks at the first few hundred lines and uses them to determine how the buffer should be indented. It then automatically updates the buffer options so that they match the opened file.

Installation

Install using your favorite package manager and then call the following setup function somewhere in your config:

require('guess-indent').setup {}

If you are using packer.nvim, you can install and set up guess-indent simultaneously:

-- using packer.nvim
use {
  'nmac427/guess-indent.nvim',
  config = function() require('guess-indent').setup {} end,
}

Usage

By default, guess-indent automatically runs whenever you open a new buffer. You can also run it manually using the :GuessIndent command.

Configuration

The plugin provides the following configuration options:

-- This is the default configuration
require('guess-indent').setup {
  auto_cmd = true,  -- Set to false to disable automatic execution
  override_editorconfig = false, -- Set to true to override settings set by .editorconfig
  filetype_exclude = {  -- A list of filetypes for which the auto command gets disabled
    "netrw",
    "tutor",
  },
  buftype_exclude = {  -- A list of buffer types for which the auto command gets disabled
    "help",
    "nofile",
    "terminal",
    "prompt",
  },
}

Normally it should not be necessary to disable the automatic execution of guess-indent, because it usually takes less than a millisecond to run, even for large files.

Alternatives

Licence

This project is licensed under the terms of the MIT license. For more detail check out the LICENSE file.

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.