indent-detector.vim icon indicating copy to clipboard operation
indent-detector.vim copied to clipboard

Plugin settings from vimrc

Open jakubkarlicek opened this issue 10 years ago • 11 comments

Using default settings or plugin only settings of tabstop, shiftwidth and softtabstop

jakubkarlicek avatar Nov 20 '15 07:11 jakubkarlicek

Added echolevel settings, related #2

jakubkarlicek avatar Nov 20 '15 08:11 jakubkarlicek

@luochen1990 Can this get merged? I came looking to see if this existed, and it does, but as an un-merged PR 😢

jrop avatar Oct 31 '19 20:10 jrop

Thanks, this is a very good PR, but I'm still wondering is there any situation which we want to use different value of tabstop, shiftwidth and softtabstop ? If there is no, then I prefer to use an option like let g:indent_detector_indentation = " " (only 1 ~ 4 spaces or tab is available here).

luochen1990 avatar Nov 01 '19 10:11 luochen1990

@luochen1990 Good point. Is @jakubkarlicek still around to update this PR?

jrop avatar Nov 01 '19 14:11 jrop

yea, will try to implement. Main point of this was to get the settings from pre-set values in .vimrc. Having separate config values was side-effect. It's true, that it's kind of useless this way

jakubkarlicek avatar Nov 01 '19 14:11 jakubkarlicek

After getting into the code, I decided to use let g:indent_detector_indentation = 4 as a config variable. It's not initialised from tabstop / shiftwidth anymore, so you have to set it manually if you want something else. It didn't make sense to make it " ", because it sets only default widths, not tab / space usage

PS.: maybe indent_detector_space_width would be better name, what do you think?

jakubkarlicek avatar Nov 01 '19 15:11 jakubkarlicek

@jakubkarlicek I think there are at least three possible designs:

first:

let g:indent_detector_indentation = 0  "for tab
let g:indent_detector_indentation = 4  "for 4 spaces

second:

let g:indent_detector_indentation = "\t"  "for tab
let g:indent_detector_indentation = "    "  "for 4 spaces

third:

let g:indent_detector_indentation = "tab"  "for tab
let g:indent_detector_indentation = "4 spaces"  "for 4 spaces

IMO, the first solution is the most easy to implement, and the last is the hardest to implement but easiest to understand for user, and the second is a balanced solution. And I can accept any of the above one :)

luochen1990 avatar Nov 07 '19 06:11 luochen1990

@jakubkarlicek And, maybe you also want to add a configuration option for autoadjust :)

luochen1990 avatar Nov 07 '19 06:11 luochen1990

@jakubkarlicek Oh, I checked this piece of logic, and find that what I want to do here, is "if we find the indentation is 'more than 4 spaces', then we set the indent sheme to be 4 spaces", so there seems not needing a default value.

My consideration here is: there are two cases when we cannot detect a leading exactly-1/2/3/4-spaces when there is indeed a leading space:

  1. the file is very special, it indeed have a more than 4 spaces indentation.
  2. the file is normal, but our nearby code is all deeply nested so we cannot find a shallow indentation.

There seems no correct solution since we cannot decide which is the real case.

We can summarize the above question as "what to do if we cannot decide how many spaces is used in indentation?"

Another real question here is: when we found that the original file have mixed indentation, what can we do with that?

And another question is: "What if there is no indentation yet" (I think here is where we need a default indentation sheme)

luochen1990 avatar Nov 07 '19 07:11 luochen1990

Another real question here is: when we found that the original file have mixed indentation, what can we do with that?

we probably cannot do much about this, I'd just use first indentation type / width which is found

And another question is: "What if there is no indentation yet" (I think here is where we need a default indentation sheme)

that's what this was trying to solve, but we don't need to handle default tab, because if you have vim set up for tabs it will just get it right after save. Only thing needed is ability to set how many spaces should be used by default

jakubkarlicek avatar Nov 12 '19 11:11 jakubkarlicek

@jakubkarlicek I have talked about 3 questions, and the code your PR influenced is about the 1st question, but according to your last post, it seems that you are trying to deal with the 3rd question. emmm... Can you confirm about which question is the one you are trying to solve?

luochen1990 avatar Nov 13 '19 03:11 luochen1990