AdamNiederer / vue-mode

Emacs major mode for vue.js
GNU General Public License v2.0
329 stars 61 forks source link

Indentation Width #86

Open BenSapiens opened 6 years ago

BenSapiens commented 6 years ago

If anyone is having the same struggle trying to change indentation width from 2 spaces to 4, try altering the variable sgml-basic-offset. I had previously altered sgml-shift-width, which was apparently sufficient for other modes, including web-mode, react-mode, rjsx-mode, and js2-mode, but not for this one.

Besides this, great experience so far.

AdamNiederer commented 6 years ago

Hm, that's strange - I don't have an sgml-shift-width in my Emacs (26.1; sgml-mode loaded). vue-mode and vue-html-mode do not directly refer to sgml-basic-offset, but are submodes of html-mode. Because of this, giving vue-mode and vue-html-mode a separate indent width would involve some hacks.

Also, please avoid using denigrating language in your issue reports. I understand this issue may be frusturating, but let's keep it professional. I've edited your initial comment accordingly.

BenSapiens commented 6 years ago

I'm using the standard Emacs installation from the emacs-plus package via Homebrew, and I do indeed have a sgml-basic-offset variable, documented and everything. In contrast, my sgml-shift-width variable isn't documented, although it's equally true that it was working fine until I ran into this package.

Continuing the thread theme of noting down little idiosyncrasies, sometime in the last month I also discovered that vue-mode semi-regularly drops the ball when it comes to reliably identifying which chunks of text are covered by which mode, necessitating a call to the vue-mode-reparse function, naturally with the (interactive) specifier. Other than that, and a related problem which similarly breaks syntax highlighting (and indentation) whenever I hit enter with my cursor positioned as follows:

<script lang="js">
                  ^
</script>

(with or without closing tag)

...it's all pretty great.

P.S. With respect, "retarded" is a description of fact, not an insult. In the world at this very moment there are retards, and they are retarded. It isn't a value judgement... unless you make it one.

fernao commented 5 years ago

Hi there, I'm also having some difficulties while changing from two to four spaces. My team adopted a Lint of four spaces and my emacs with vue-mode is using two! At the moment, I can only indent with four using other modes - such as web-mode etc.

Any ideas??

BenSapiens commented 5 years ago

@fernao

Hi there, I'm also having some difficulties while changing from two to four spaces. My team adopted a Lint of four spaces and my emacs with vue-mode is using two! At the moment, I can only indent with four using other modes - such as web-mode etc.

Any ideas??

Assuming you haven't already figured this out, have a look at the variable tab-width. For me, at least, it has sometimes overridden other values I've set elsewhere.

Furthermore, in general, I recommend attempting to introspect Emacs with the describe-key, describe-function, and describe-variable helper functions, accessible by default with C-h k, C-h f, and C-h v, respectively.

fernao commented 5 years ago

I've come to a solution, that attends to the lint rules of the project:

When I'm editing inside <template>area on a .vue file, i use web-mode. When editing code inside the <script>, i use vue-mode. It worked for me.