Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Add scoped settings to user config - #3718

Merged
benogle merged 26 commits into
masterfrom
bo-scoped-user-config
Oct 8, 2014
Merged

benogle merged 26 commits into
masterfrom
bo-scoped-user-config

Conversation

@benogle

@benogle benogle commented Oct 3, 2014

Copy link
Copy Markdown
Contributor

Status: Donezo

Building on #3674, the plan is to allow for scoped configuration of editor settings. This solves the problem of "I only want to soft wrap in markdown documents", "I need hard tabs for make", "I want 2 space tabs for ruby and 4 space tabs for python", etc.

The settings

Here are the settings I plan on scoping:

# Scoping these is obvious to me
editor.softTabs
editor.tabLength
editor.softWrap
editor.softWrapAtPreferredLineLength
editor.showInvisibles
editor.showIndentGuide
editor.nonWordCharacters

# Scoping these seems good, but maybe not
editor.invisibles
editor.autoIndent
editor.normalizeIndentOnPaste

Language packages will be able to set these settings in their scoped-properties cson files.

Comment if you have suggestions about settings that should / should not be scoped.

User config file format

The user will also be able to override these settings in their config file. The plan right now is to place all the current settings under a global key, then any overridden scoped settings under their scope. Check it:

'global':
  'editor':
    'fontSize': 14
    'fontFamily': 'monaco'
    'tabLength': 4
  'core':
    'themes': [
      'atom-light-ui'
      'atom-light-syntax'
    ]
'.source.gfm':
  'softWrap': true
'.source.gfm .code':
  'softWrap': false
'.source.ruby':
  'tabLength': 2

In this example, all languages other than ruby will use 4 space tabs, and ruby will use 2. Additionally, markdown files will be wrapped. One neat thing, because of scoping, is that code blocks in markdown will not be wrapped in this case.

Backward compatibility

The config file will be read in as it is today. It will check for a global key, and if not there assume the old format. Upon writing the file back out, it will write out with global config under the global key.

TODO

  • scope editor.tabLength
  • scope editor.softWrap
  • scope editor.softWrapAtPreferredLineLength
  • scope editor.preferredLineLength
  • scope editor.scrollPastEnd
  • scope editor.showInvisibles
  • scope editor.showIndentGuide
  • scope editor.nonWordCharacters
  • scope editor.invisibles
  • scope editor.autoIndent
  • scope editor.normalizeIndentOnPaste
  • showLineNumbers (punting. Will scope and fix gutter hiding in one unit of work)
  • scope editor.softTabs (punting for now. Later: Add new editor.tabType scoped setting #3719)
  • read / write new config format
  • Merge Add ::propertiesForSource scoped-property-store#3

Prior Art

Refs #2593, atom/language-make#3, #2917
Depends on #3697, atom/scoped-property-store#3

@benogle benogle self-assigned this Oct 3, 2014
@benogle benogle mentioned this pull request Oct 3, 2014
18 of 25 tasks
@mark-hahn

Copy link
Copy Markdown
Contributor

Comment if you have suggestions about settings that should / should not
be scoped.

One vote for allowing all to be scoped. It makes life simple and I see no
harm.

On Fri, Oct 3, 2014 at 12:30 PM, Ben Ogle [email protected] wrote:

status: WIP: opening super early again.

Building on #3674 #3674, the plan is
to allow for scoped configuration of editor settings. This solves the
problem of "I only want to soft wrap in markdown documents", "I need hard
tabs for make", "I want 2 space tabs for ruby and 4 space tabs for python",
etc.
The settings

Scoping these is obvious to meeditor.softTabseditor.tabLengtheditor.softWrapeditor.softWrapAtPreferredLineLengtheditor.showInvisibleseditor.showIndentGuideeditor.nonWordCharacters

Scoping these seems good, but maybe noteditor.invisibleseditor.autoIndenteditor.normalizeIndentOnPaste

Language packages will be able to set these settings in their
scoped-properties cson files.

Comment if you have suggestions about settings that should / should not be
scoped.
User config file format

The user will also be able to override these settings in their config
file. The plan right now is to place all the current settings under a
global key, then any overridden scoped settings under their scope. Check
it:

'global':
'editor':
'fontSize': 14
'fontFamily': 'monaco'
'tabLength': 4
'core':
'themes': [
'atom-light-ui'
'atom-light-syntax'
]'.source.gfm':
'softWrap': true'.source.gfm .code':
'softWrap': false'.source.ruby':
'tabLength': 2

In this example, all languages other than ruby will use 4 space tabs, and
ruby will use 2. Additionally, markdown files will be wrapped. One neat
thing, because of scoping, is that code blocks in markdown will not be
wrapped in this case.
Backward compatibility

The config file will be read in as it is today. It will check for a global
key, and if not there assume the old format. Upon writing the file back
out, it will write out with global config under the global key.

Refs #2593 #2593,
atom/language-make#3 atom/language-make#3,
#2917 #2917

Depends on #3697 #3697

You can merge this Pull Request by running

git pull https://github.com/atom/atom bo-scoped-user-config

Or view, comment on, or merge it at:

#3718
Commit Summary

  • Move internal things into an internal section
  • Basic scoped settings in Config works
  • Reorganize private methods into section
  • fix value and default value object checks
  • Shift the args before coercing the value
  • Remove unused method
  • Syntax calls into atom.config for scoped properties
  • Add deprecations to the syntax scoped property methods
  • Fix specs for settings view.
  • Use config in spec helper
  • rename method
  • Use config rather than syntax for scoped properties
  • Use disposables for removing properties
  • Remove special method for language mode
  • Fix specs
  • Remove +default junk
  • Ugh, add settingsForScopeDescriptor back
  • Can remove the clearing of scoped properties
  • addScopedDefaults -> addScopedSettings
  • Pull observing out into special methods for global config
  • Implement observing on scoped properties
  • 📝 Update docs for scoped settings
  • Add schemas for scoped configs
  • Moar 📝
  • 💄
  • Scope usage of editor.nonWordCharacters

File Changes

Patch Links:

—
Reply to this email directly or view it on GitHub
#3718.

@benogle

benogle commented Oct 3, 2014

Copy link
Copy Markdown
Contributor Author

All I listed, or all in the editor? I was planning on scoping all I listed.

@lee-dohm

lee-dohm commented Oct 4, 2014

Copy link
Copy Markdown
Contributor

@benogle If editor.preferredLineLength was scoped, that would allow wrap-guide to be simplified perhaps?

See: atom/wrap-guide#15

Two other questions:

  1. Is this something that packages can use also? Perhaps the wrap-guide behavior I pointed out just needs to be refactored rather than removed?
  2. Are you looking for feedback on project-specific settings or is this just for language-specific settings?

@benogle

benogle commented Oct 6, 2014

Copy link
Copy Markdown
Contributor Author

Yes, this would simplify that PR. It would just need to read the config based on the grammar's scope.

  1. Fo sho. Packages can use this exactly like core does.
  2. This is only language, or scope specific settings. Project specific settings will likely end up being some kind of .atom file at the root of a project.

@benogle
benogle force-pushed the bo-scoped-user-config branch from ad188e1 to f03ca5f Compare October 6, 2014 21:12
@lee-dohm

lee-dohm commented Oct 7, 2014

Copy link
Copy Markdown
Contributor

Project specific settings will likely end up being some kind of .atom file at the root of a project.

I was thinking something similar.

Comment thread spec/text-editor-component-spec.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like specs to read correctly including the word "it". What about: it "assigns ::softWrapped based on the top-level grammar scope"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually no longer assigns ::softWrapped unless explicitly set by the ::setSoftWrapped method.

Comment thread src/tokenized-buffer.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support variable length tabs in a single file currently. Does it make sense to take a scopeDescriptor considering that fact? Should we always just use the root?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I should take this out. I had dreams of making it support different lengths within the file based on cursor scope.

@benogle

benogle commented Oct 7, 2014

Copy link
Copy Markdown
Contributor Author

Depends on atom/scoped-property-store#3

@nathansobo

Copy link
Copy Markdown
Contributor

👏 Glad you took the time to scope all these properties. People are going to be happy they can finally do per-grammar settings.

  • I think all the spec descriptions need to be reworded into more general language that's not based on the grammars you happen to be using as examples.
  • Suggested some renames / API adjustments. We should call it a scope descriptor everywhere.
  • I'm concerned about leftovers fromTextMate in the format of scope descriptors. Are we still using foo.bar instead of .foo.bar anywhere public?

@benogle

benogle commented Oct 8, 2014

Copy link
Copy Markdown
Contributor Author

I am happy with this. Plan on merging tomorrow.

@benogle
benogle force-pushed the bo-scoped-user-config branch from 1906c68 to c154b8f Compare October 8, 2014 23:03
benogle added a commit that referenced this pull request Oct 8, 2014
Add scoped settings to user config
@benogle
benogle merged commit 17bfc29 into master Oct 8, 2014
@lee-dohm

lee-dohm commented Oct 8, 2014

Copy link
Copy Markdown
Contributor

Messing around with this so far right now ... works great! 👏 🎉

@benogle
benogle deleted the bo-scoped-user-config branch October 9, 2014 00:53
@thomasjo

thomasjo commented Oct 9, 2014

Copy link
Copy Markdown
Contributor

This is bloody brilliant! Can kill the Overrides package now, created by @lee-dohm and myself. Yeehaaaw 😁

@lee-dohm

lee-dohm commented Oct 9, 2014

Copy link
Copy Markdown
Contributor

@thomasjo Well, maybe wait until v0.137.0 gets released. I only use official releases on my work computer 😆

@phoenixgao

phoenixgao commented Oct 26, 2016 •

Copy link
Copy Markdown

What's the final format for this configure?

Totally lost by here and can't get it work in my Atom 1.10.2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants