I would love to have in Atom a kind of alternative to the Sublime Text package
Php Companion that allow importing namespaces and classes.
I'm trying to figure out how works this functionality in the atom-autocomplete-php plugin.
In the Documentation there are this functionalities listed:
Autocompletion of class names and automatic adding of use statements where needed.
Add use statement of class under cursor (ctrl-alt-u)
So I aspect that when I need to import a class in my PHP file when I write use...
I would get a series of options, but the composer packages I have required are not listed in my list.
If I press ctrl-alt-u or ctrl-cmd-u nothing happens. (I'm using a MAC)
How does it work?
I found out that there is some sort of incompatibility for the pre-defined key bindings on OsX.
I have solved re-mapping the key bindings for the autocomplete namespace and for the import-use-statements
Now instead of ctrl-alt-u and ctrl-alt-n i have re-mapped to cmd-alt-u and cmd-alt-n.
To do that:
Open Atom > Preferences > Keybindings.
Create a personal Keymap file clicking on "your keymap file".
Added this code in the file.
This is the code:
'atom-text-editor':
'cmd-alt-u': 'atom-autocomplete-php:import-use-statement'
'cmd-alt-n': 'atom-autocomplete-php:namespace'
Related
I know I have a file called 'mwc-fab' in my dependency,
so How can I search this file with the file name?
In vscode, i just type mwc with my node_modules file select and I get the file I want.
If you're using a Windows computer the command is Ctrl+T or Ctrl+P and on Mac Cmd+T or Cmd+P
https://flight-manual.atom.io/getting-started/sections/atom-basics/
There is an Atom package named incremental search that you can use to search thru open files. After installing incremental-search you can type command-i and this opens a text box near bottom of screen where you can input your search string. After that you can command-i repeatedly to go to next matching string. Be sure to read the directions for more useful commands.
In sublime text 2 I simply used Enhanced-R in order to use the cmd+enter hot key to evaluate a snippet of code in SublimeREPL or the native R app. As far as I can tell, this package doesn't exist for ST3. So, might I change the key binding, currently, control+,,l (control and comma, then l), to cmd+enter?
I imagine I need to modify the file found here: Preferences > Package Settings > SublimeREPL > User or Preferences > Keybindings - User, but am not sure which or what to add.
Thanks for any leads.
Check out R-Box. Enhanced R was rewritten some time ago as R-Box, both are by the same author - R-Box mainly has much extended functionality, including a new menu when .R files are active. ⌘Enter (or CtrlEnter on other operating systems) should still work the same way. You'll have to redo your customized settings, of course, but all in all the new plugin is nicer and has many more features than the old one.
I am writing an angular2-meteor program.
When I am using urigo:angular2-meteor package, I add reference path like this:
/// <reference path="../typings/angular2-meteor.d.ts" />
The question is: can I use other normal meteor packages in a angular2-meteor project? Or I can only use some packages written for angular2-meteor specifically.
For example, if I want to use yuukan:streamy, how can I use it correctly? Right now, I have one line code
Streamy.broadcast('hello', {data: 'world!'});
When I compile it, it shows: Cannot find name 'Streamy'.
Thanks!
you can use all the libraries from meteor.
you will have 2 choices.
find the streamy definition file (streamy.d.ts) if it exists. This will give you autocompletion and compile errors if you misuse streamy functions.
If you dont find a definition file than just add declare var Streamy at the top of the file you want to use it. The library is already there if you add it via atmosphere. But typescript does not know about it. By declaring the variable you tell typescript that this exists and it wont complain when compiling.
Newly created files in Atom are always "Plain Text". How can I change this so that new files will automatically be in another language, for example "Shell Script (Bash)"? I want to do this because auto indentation does not work with Plain Text files.
Had this problem as well, there is a plugin called default-language that will do this for you.
Search atom for default-language, install and open its settings. Type the name of the language you want Atom to default to, e.g. Shell Script (if in doubt, copy from the language selection menu) in the Default Language field. Next time you open a script with no extension (or shebang) it'll default to the language you set.
The following code, added to your init.coffee, will do what you're asking:
atom.workspace.observeTextEditors (editor) ->
default_scope = 'source.shell'
original = editor.getGrammar()
# If the editor has "null" grammar (aka unset)
if original? and original is atom.grammars.grammarForScopeName('text.plain.null-grammar')
default_grammar = atom.grammars.grammarForScopeName(default_scope)
if default_grammar? # check if desired grammar is already loaded
editor.setGrammar(default_grammar)
else
# grammar was not loaded yet, so add a callback as grammars load
callback = atom.grammars.onDidAddGrammar (grammar) ->
if grammar.id is default_scope
# once we've loaded the grammar, set it and dispose of the callback
editor.setGrammar(grammar)
callback.dispose()
Things to note:
The init.coffee file is where you can customize Atom without having to write a package
The observeTextEditors method sets a callback that is called upon each TextEditor creation for currently open and future editors
The code above:
Checks the grammar that the editor was created with
If and only if it is the default ("null") grammar, it sets the editor's grammar to the Shell grammar once it's loaded
Disposes of the callback to check for grammar loading once it's done with it
This should solve the TypeError: Cannot call method 'getScore' of undefined that happens for the first file opened in a new window.
To default to a different grammar, just change the default_scope = 'source.shell' line to use the scope of whatever grammar you'd like.
Firstly, CTRL+SHIFT+L is your friend. It's unfortunately not a permanent solution, but nice to know about.
Of course, we'd prefer a more permanent solution. A couple of the other answers are now obsolete due to API changes in Atom. Below is a more up-to-date version. Inspiration initially came from this discussion, but the other answers here seem to follow the same concept as well.
Place this in your init.coffee file (File -> Open Your Init Script):
extname = require("path").extname
fileTypes =
".wxs": "text.xml"
".wxi": "text.xml"
".wixobj": "text.xml"
nullGrammar = atom.grammars.selectGrammar("text.plain.null-grammar")
atom.workspace.observeTextEditors (editor) ->
grammar = atom.grammars.selectGrammar(fileTypes[extname(editor.getPath())])
editor.setGrammar grammar if editor.getGrammar() is nullGrammar and grammar isnt nullGrammar
Basically, you define have an array of file types, and the grammars (AKA syntax highlighting) that you want to associate them with. Find each editor, find out if it has a selected grammar already, and if not, attempt to give it one if we find one.
The one issue I've had with this is that the syntax highlighting only works if you open files after you've already launched Atom; if you open a file that results in Atom launching (say by double clicking on it's icon in your favourite OS), syntax highlighting won't for that file until you re-open it.
You need to create a mapping in your config.cson file.
"*":
core:
customFileTypes:
"source.shell": [
"sh"
"shell"
]
For mapping .sh and .shell files to shell script syntax.
Have a look at this bit of code: (you can can then change 'text.html.basic' to whichever syntax you require)
editor = atom.workspace.getActiveTextEditor()
cursor = editor.getLastCursor()
valueAtCursor = atom.config.get(cursor.getScopeDescriptor(), 'my-package.my-setting')
valueForLanguage = atom.config.get(editor.getRootScopeDescriptor('text.html.basic'), 'my-package.my-setting')
For reference please see: Scope Descriptors # https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors
I want to use SoundFacade class from Adobe. (Here, from github). I simple created an "ActionScript File" and paste all the code. But when I want to compile my app I got following error:
1037: Packages cannot be nested.
The only reason I can guess is that the package must somehow put into the project or something.
EDIT:
Even when I just put a simple empty package I got the error:
package {
}
How to Reproduce the bug?
Create a new Flex Mobile Project.
Click New > ActionScript File
type package { }
include new package in one your views
code:
<fx:Script source="../SoundFacade.as" />
You will get the error
I find the solution. I was actually unaware of the package naming rule. Here is the answer to this problem: http://forums.adobe.com/message/4299377
The tag will insert your
SoundFacade.as file into the MXML file (similar to an include in
C/C++). That will cause an invalid syntax.
Give your package a name (in this case it should be called SoundFacade
because that is the name of the folder it is in) then use the import
statement inside your script tag. Make sure you adhere to the
recommended file, namespace, package and class naming structure.
That's usually a reverse-DNS style: com.adobe.utils.bla.bla.bla.
If package name is blank and the source is in the default folder, you
don't need to import it.