Skip to content

annarailton/sublime-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Awesome sublime stuff

To get these to work in a fresh install of sublime, you first need to install Package Control. The packages should then all install automatically.

There are some extras to install (mainly linters). This assumes Python 3.6+:

sudo apt-get install libxml2-utils
pip install mypy
pip install pylint
pip install yapf

Packages

UI

Text related

  • HighlightWords - custom highlighting of e.g. TODO or DEBUG
  • InsertDate - insert current data/time (bind to keyboard shortcuts)
  • MarkdownEditing - robust syntax highlighting for Markdown
  • Markdown Extended - more different Markdown syntax highlighting (does a better job of inline code highlighting, worse at bullets)
  • MarkdownPreview - allows for easy Markdown preview in the browser
  • MarkdownTOC - adds Markdown table of contents
  • PlainTasks - nice todo lists
  • Pandoc - convert between different markup formats
  • Table Editor - makes editing text tables much better
  • Rainbowth - Rainbow parantheses for Lisps
  • Parinfer - Smart parentheses for Lisps

General programming

Python

  • AutoDocstring - insert/update docstrings
  • Sublime JEDI - Code intel for Python
  • Python Fix Imports - gets imports correctly ordered and formatted
  • PyYapf Python Formatter - runs the YAPF Python formatter. Note that in order for it to not break with dictionary unpacking **my_dict you need the Python3.6+ version of yapf. See here for instructions on how to set up Python3.6 and pip3.6. Then just do
pip3 uninstall yapf 
pip3.6 install yapf
whereis yapf
  • SublimeLinter-pylint - because you need a Python linter

Meta

Misc

  • Carbon - making code snippets for presentations etc. (without having to print screen everything!)

Making custom commands (keymap, command palette)

As an example, consider running autoflake on Python files you are editing. (autoflake is a Python tool that trims used imports and variables.)

You will need the following Python script saved in your .config/sublime-text-3/Packages/User folder (see here)

Custom command

# autoflake.py

import sublime_plugin

import subprocess


class AutoflakeRemoveUnusedImportsCommand(sublime_plugin.TextCommand):
    def run(self, edit, **kwargs):
        subprocess.check_call([
            # '/usr/local/bin/autoflake',
            '/home/railton/environments/default_3/bin/autoflake',
            '--in-place',
            '--remove-all-unused-imports',
            self.view.file_name(),
        ])

Command palette

Append the following to Default.sublime-commands to have it available via the command palette.

[
    // ...
    { "caption": "Custom: Autoflake Remove Unused Imports", "command": "autoflake_remove_unused_imports" }  
]

Keymap

To do key binding, append the following to Default (Linux).sublime-keymap:

[
    // ...
    { "keys": ["ctrl+alt+g"], "command": "autoflake_remove_unused_imports",
    "context": [
            { "key": "selector", "operator": "equal", 
            "operand": "source.python" }
        ]
    }
]

Activate upon save

To activate upon save you will need the Hooks package, and to add the following to Preferences.sublime-settings:

{
    // ...
    "on_post_save_user":
        [
            {
                "command": "autoflake_remove_unused_imports"
            }
        ],
}

N.B. don't actually do this as it can be pretty annoying - implementing it as a pre-commit hook is a much better idea (see this gist for more info).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages