Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Setting up Sublime2: Difference between revisions

From MoodleDocs
m (Marking this document as obsolete)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{obsolete}}
According Wikipedia ''Sublime Text is a cross-platform text and source code editor, with a Python API. The chrome was inspired by Vim. Its functionality is also extendable with sublime-packages; Sublime Text is not open source software nor free software, but some of the extending packages have free-software licenses and are community-built and maintained.''
According Wikipedia ''Sublime Text is a cross-platform text and source code editor, with a Python API. The chrome was inspired by Vim. Its functionality is also extendable with sublime-packages; Sublime Text is not open source software nor free software, but some of the extending packages have free-software licenses and are community-built and maintained.''


Line 50: Line 52:
I recommend to enable only the Linter and the PHP Coding Standard Fixer. Mess Detector and Scheck may help a lot but they not fit well with some Moodle coding rules.  
I recommend to enable only the Linter and the PHP Coding Standard Fixer. Mess Detector and Scheck may help a lot but they not fit well with some Moodle coding rules.  


The PHP Coding Standard Fixer check the code using the PEAR standard, for installing the Moodle standard you need to:
The PHP Coding Standard Fixer check the code using the PEAR standard, for installing the Moodle standard you can install using PEAR or manually install it.
 
1 Install the Pear package for PHP CS, http://pear.php.net/package/PHP_CodeSniffer/redirected
 
2 Download the standard: phpcompatibility and moodle directories from https://github.com/moodlehq/moodle-local_codechecker
 
3 Copy the previous directories to the PHP CS standard path,
* in Mac with Macports is /opt/local/lib/php/PHP/CodeSniffer/Standards/
* in Linux is /usr/share/php/PHP/CodeSniffer/Standards/


4 Edit the settings for the PHP CodeSniffer package, change this:
'''Install using pear installer'''


1. Install PHP CS using PEAR installer following steps described in https://docs.moodle.org/dev/CodeSniffer#Installing_PHP_CS


2. Edit the settings for the PHP CodeSniffer package, change this:
<syntaxhighlight lang="php">
     "phpcs_additional_args": {
     "phpcs_additional_args": {
         "--standard": "moodle",
         "--standard": "moodle",
         "-n": ""
         "-n": ""
     },
     },
</syntaxhighlight>
You can delete the -n option if you want to see also Warnings


<syntaxhighlight lang="php">
    // This display warnings also.
    "phpcs_additional_args": {
        "--standard": "moodle"
    },
</syntaxhighlight>
You can put the previous directories in a different directory and change the --standard value to point to that directory
You can put the previous directories in a different directory and change the --standard value to point to that directory


http://soulbroken.co.uk/code/sublimephpcs
'''Manually install (to avoid dependencies issues)'''
 
1 Download the phpcs.phar bundle from the author web page: https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.5.8/phpcs.phar (remember to chmod +x the phpcs.phar file)
 
2 Clone the https://github.com/moodlehq/moodle-local_codechecker repo into a local directory
 
3 Edit the settings for the PHP CodeSniffer package, change this:
 
    "phpcs_executable_path": "/path/to/phpcs.phar",
    "phpcs_additional_args": {
        "--standard": "/path/to/moodle-local_codechecker/moodle",
        "-n": ""
    },


===  DockBlockr ===
===  DockBlockr ===
Line 101: Line 120:


http://github.com/Kronuz/SublimeCodeIntel
http://github.com/Kronuz/SublimeCodeIntel
[[Category:Developer tools|Sublime]]

Latest revision as of 03:17, 28 April 2022

Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.


According Wikipedia Sublime Text is a cross-platform text and source code editor, with a Python API. The chrome was inspired by Vim. Its functionality is also extendable with sublime-packages; Sublime Text is not open source software nor free software, but some of the extending packages have free-software licenses and are community-built and maintained.


Sublime Settings

For Moodle Development:

Preferences -> Settings (default or user)

Tab size and spaces:

   "tab_size": 4,
   
   // Set to true to insert spaces when tab is pressed
   "translate_tabs_to_spaces": true,
   
   "rulers":
   [
       132
   ],

Sublime plugins for PHP and Moodle Development

For installing new plugins in Sublime2, the best way is to use the Sublime Package Control, see installation instructions

SublimeMoodle

By Frédéric Massart

  • Auto completion for functions, classes and constants.
  • Helper to write testing instructions (Command palette > Moodle: Write testing instructions)
  • Open a tracker issue based on user input (Command palette > Moodle: Open a tracker issue)
  • Open a tracker issue based on text selection or current branch (Command palette > Moodle: Resolve and open tracker issue)

You need to install it manually or add a new Package Control repository

https://github.com/FMCorz/SublimeMoodle


Trailing Spaces

A Sublime Text 2 and 3 plugin that allows you to highlight trailing spaces and delete them in a flash!

https://github.com/SublimeText/TrailingSpaces

Sublime PHP CS

PHP CodeSniffer, PHP Coding Standard Fixer, Linter, Mess Detector and Facebook Scheck Support for Sublime Text

I recommend to enable only the Linter and the PHP Coding Standard Fixer. Mess Detector and Scheck may help a lot but they not fit well with some Moodle coding rules.

The PHP Coding Standard Fixer check the code using the PEAR standard, for installing the Moodle standard you can install using PEAR or manually install it.

Install using pear installer

1. Install PHP CS using PEAR installer following steps described in https://docs.moodle.org/dev/CodeSniffer#Installing_PHP_CS

2. Edit the settings for the PHP CodeSniffer package, change this:

    "phpcs_additional_args": {
        "--standard": "moodle",
        "-n": ""
    },

You can delete the -n option if you want to see also Warnings

     // This display warnings also.
    "phpcs_additional_args": {
        "--standard": "moodle"
    },

You can put the previous directories in a different directory and change the --standard value to point to that directory

Manually install (to avoid dependencies issues)

1 Download the phpcs.phar bundle from the author web page: https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.5.8/phpcs.phar (remember to chmod +x the phpcs.phar file)

2 Clone the https://github.com/moodlehq/moodle-local_codechecker repo into a local directory

3 Edit the settings for the PHP CodeSniffer package, change this:

   "phpcs_executable_path": "/path/to/phpcs.phar",

   "phpcs_additional_args": {
       "--standard": "/path/to/moodle-local_codechecker/moodle",
       "-n": ""
   },

DockBlockr

Simplifies writing DocBlock comments in Javascript, PHP, CoffeeScript, Actionscript, C & C++

Just type /** and tab ... It will preload the fool dock skel (tab between vars for quick editing)

https://github.com/spadgos/sublime-jsdocs

Sidebar Enhancements

Enhancements to Sublime Text sidebar. Files and folders.

https://github.com/titoBouzout/SideBarEnhancements

Bracket Highlighter

Bracket and tag highlighter for Sublime Text 2

https://github.com/facelessuser/BracketHighlighter

Sublime CodeIntel

Full-featured code intelligence and smart autocomplete engine

Avoid to index XML files (it will crash with Moodle), Shift + Click for jumping to function definitions

I recomend you to index only the Moodle lib/ folder (include the folder in your project in order to allo CodeIntel to index it)

http://github.com/Kronuz/SublimeCodeIntel