Git Product home page Git Product logo

guess-indent.nvim's Issues

Not detect tabs with size 4

Thanks for this plugin.

guess-indent not detect tabs with size 4.

Example using lua file.

2022-03-04_15-33_54.mp4

Will not automatically start the plugin.

Hi,

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

Trying out this plugin with the config from the readme.

Sadly the autostart is not working. Even with auto_cmd=true.

I need to manually call GuessIndent to get it work. :(

Any idea? Do you need more info? Do i need to setup the plugin in an specific order?

Feature Suggestion: also set `listchars` depending on tabs/spaces

I find it useful to only show tab via listchars when using spaces and vice versa, since that allows me to quickly identify the use of the wrong type of indention in a file.

Currently, I run a simple autocommand like this to adjust listchars depending whether the buffer uses tabs or spaces:

autocmd("BufReadPost", {
	callback = function()
		-- defered, to ensure it runs after `:GuessIndent`
		vim.defer_fn(function()
			opt_local.listchars = vim.opt_global.listchars:get() -- copy the global
			if bo.expandtab then
				opt_local.listchars:append { tab = "? " }
				opt_local.listchars:append { lead = " " }
			else
				opt_local.listchars:append { tab = "  " }
				opt_local.listchars:append { lead = "" }
			end
		end, 5)
	end,
})

I was thinking that adjusting listchars would actually make a lot of sense for in the context of this plugin (and would also save one from using hacky solutions like deferring that autocmd)

User config is ignored if `auto_cmd` is set to false

The file types and buffer types to exclude are ignored when auto_cmd is set to false. However, I only disabled the autocmd so I could call guess-indent from my own autocmd, to allow for more control over when it's run relative to other indentation-related configuration.

Currently I'm manually calling require("guess-indent").set_from_buffer(true) from my own autocmd, but it would be great if there was a command, or perhaps an argument that could be passed to :GuessIndent, that would respect the user config regardless of what auto_cmd is set to.

Turn off Notifications?

I noticed that the plugin seems to creates a prints a notification every time it sets the indentation.

While that may be useful for when you manually run :GuessIndent or when the indentation values have been changed, it is a bit annoying when the notification appears every time you enter a new buffer, even if the indentation was already set correctly?

non-issue: readme.md: add lazy and retab keymaps

Hi,
thank you so much for making this plugin!!

Below is my lua for lazy, you could add that to the readme.

I've also added the following keybindings:

<Tab>g to guess the indetation
<Tab>t to convert to tabs (normal mode)
<Tab>t to convert to tabs (visual line mode)
<Tab>s to convert to spaces (normal mode)
<Tab>s to convert to spaces (visual line mode)

While the last two (four) bindings don't have anything to do with your plugin, you may still choose to add them to the readme as they provide a great workflow enhancement when converting styles.

return {
	'nmac427/guess-indent.nvim',
	lazy = false,
	config = function()
		require('guess-indent').setup {}
		vim.keymap.set('n', '<Tab>g', vim.cmd.GuessIndent, { desc = "GuessIndent (manual)" })
		-- to tabs
		vim.keymap.set('n', '<Tab>t', '<Cmd>set noexpandtab<CR><Cmd>%retab!<CR><Cmd>set tabstop=8<CR>', { noremap = true, desc = "retab to tabs" })
		vim.keymap.set('v', '<Tab>t', "<Cmd>set noexpandtab<CR><Cmd>'<,'>retab!<CR><Cmd>set tabstop=8<CR>", { noremap = true, desc = "retab to tabs" })
		-- to spaces (for the average emacs enjoyer)
		vim.keymap.set('n', '<Tab>s', '<Cmd>set expandtab<CR><Cmd>set tabstop=8<CR><Cmd>%retab!<CR>', { noremap = true, desc = "retab to spaces" })
		vim.keymap.set('v', '<Tab>s', "<Cmd>set expandtab<CR><Cmd>set tabstop=8<CR><Cmd>'<,'>retab!<CR>", { noremap = true, desc = "retab to spaces" })
	end,
}

For beginners like me, these would be quite helpful.

How to use GuessIndent plugin and ftplugin files ?

Hello, thanks for your work on GuessIndent plugin : it's a great tool for my neovim usage.

I'm using ftplugin files for C, Go and Python to automatically configure my indent settings (filetype plugin indent on in configuration). For example, ftplugin/python.vim :

setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4
setlocal smarttab
setlocal expandtab

How to use your plugin to set automatically indentation with ftplugin files ? If your plugin detects an indentation different from my configuration, what configuration will be used ?
I want to use my default configuration for C, Go and Python when I work on my projects but I would like to use automatic indentation detected by GuessIndent when I work on external project (common usage : C project indented with TAB of 8, 4 spaces for indent in my personal config for C).

Silence :GuessIndent command output?

I disabled the automatic execution of guess-indent and started calling vim.api.nvim_command("GuessIndent") in one of my own autocmds so I can dynamically adjust listchars based on the file's indentation.

But now I'm getting messages about the indentation being set (eg, Did set indentation to tabs.) Is there a way to silence those messages?

Google C++ style

Google C++ style place class member access specifier in 3 spaces indent, which make guess-indent set indent to 1 space. In practice this should be 4 spaces.
A simple example:

class Example {
   public:
    Example() {}
};

can we support this as a special case?

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.