Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Clojure/Clojurescript smart indent is always 4 spaces #86

Open
steveaft opened this issue May 10, 2016 · 6 comments
Open

Clojure/Clojurescript smart indent is always 4 spaces #86

steveaft opened this issue May 10, 2016 · 6 comments

Comments

@steveaft
Copy link

I've looked through the issues on this repo, and looked through issues on Google Groups, but don't quite know what would be different about my setup -- I don't see any of the behaviors related to clojure formatting correctly.

I just have a regular lighttable install, and I have the closure plugin (latest 0.3.2) I almost always get 4 space indents --

(defn
    more stuff...

Am I supposed to override something somewhere, or hack the codemirror file actually get 2 space indents?

I have my tabs set to 2 spaces, and if I move the cursor to the leftmost column and hit "tab" I actually get two spaces, so this seems to only be an issue with smart indent, which seems to trigger anytime I hit the enter key

@steveaft steveaft changed the title Closure/Clojurescript smart indent is always 4 spaces Clojure/Clojurescript smart indent is always 4 spacesj May 10, 2016
@steveaft steveaft changed the title Clojure/Clojurescript smart indent is always 4 spacesj Clojure/Clojurescript smart indent is always 4 spaces May 10, 2016
@carocad
Copy link
Contributor

carocad commented May 11, 2016

hey @steveaft,
I think this is a configuration problem, not a bug.

This is my personal tab configuration for Lighttable:
[:editor :lt.objs.editor/tab-settings false 4 2]
You should have something similar in your user.behaviors, if you don't know what that is simply open the command panel, type user behavior and open it. You should be able to configure your tab/spaces whichever way you want. The config that I showed above says to use spaces instead of tabs (false), and indents everything with 2 spaces. tabs are configured to be 4 spaces.

hope that helps

@steveaft
Copy link
Author

I agree it is probably some configuration issue but can't figure out what.
When I have some time to look again I'll probably add logging statements to the codemirror files and the lighttable ones

I have my tabs set to false 4 4, for :editor, but I tried yours with same effect. Here is what I have:

 [:editor :lt.objs.editor/tab-settings false 4 4]
 [:editor.clojure :lt.objs.editor/tab-settings false 2 2]
 [:editor.clojurescript :lt.objs.editor/tab-settings false 2 2]

But if I select a chunk of code and hit shift-tab (smart indent) it doesn't seem to do the two-space indenting (nor if I split a line with a carriage return)

So if I have

(defn x [] 
  (log "foo"))

and I smart indent, it ends up as

(defn x []
    (log "foo"))

If I manually delete the whitespace in front of (log "foo"), then put my cursor at the start of the line and hit tab, it indents 2 spaces

If I look at the codemirror clojure file it seems like it should end up knowing my tab is 2 spaces but I get 4 on the smart indent.

@carocad
Copy link
Contributor

carocad commented May 12, 2016

mmm weird,
I can't reproduce this behavior in my LT. I used your configuration and everything works fine.
Could you tell me your system and LT specifications?

And as a remark: did you manually make the shift + tab keybinding in your LT? because I don't have that keybinding, so do it through the command panel and it works fine with the function and configuration that you gave me. Could you try that please?

PS: I get a similar behavior only when working outside of clojure(script) files, for example, if I try shift + tab in a behaviors file, it inserts two extra spaces at the beginning of the line. But that is a correct behavior since your configuration is 4 4 for any editor that is not clojure(script). If I put it in 2 2 then everything works as expected.

@steveaft
Copy link
Author

steveaft commented May 12, 2016

Hmm I don't have shift-tab set to anything, it just seems to always have the same effect as running the smart indent command. I also installed keymapper plugin, and don't see shift-tab set to anything.

Running smart-indent through the command panel has the same effect.

If I take a cljs file, set the syntax to something else like "C++", then I do smart-indent, it indents quite differently (1 space indents in that case), so it seems that somehow it is the clojure plugin.

I'm running on a mac, latest os, all updates installed.
lighttable 0.8.1

@kenny-evitt
Copy link

@steveaft You mentioned you have the Keymapper plugin installed. What other plugins do you have installed? Would you try reproducing this with a clean install without any other plugins (other than the defaults) installed? See this issue for details on uninstalling everything:

@steveaft
Copy link
Author

I did try uninstalling plugins but didn't do a complete purge. I'll give that a try

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants