Skip to content

Commit

Permalink
Initial settings - VAIO
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasrcosta committed Jan 9, 2014
0 parents commit 0ef63d5
Show file tree
Hide file tree
Showing 29 changed files with 518 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Empty file added CodeFormatter.sublime-settings
Empty file.
9 changes: 9 additions & 0 deletions Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{ "keys": ["ctrl+shift+;"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"} },
{"keys": ["ctrl+;"],"command": "run_macro_file","args": {"file": "Packages/User/endsemicolon.sublime-macro"}
},
{"keys": ["ctrl+shift+'"],"command": "run_macro_file","args": {"file": "Packages/User/quotes.sublime-macro"}
},
{"keys": ["ctrl+'"],"command": "run_macro_file","args": {"file": "Packages/User/simplequotes.sublime-macro"}
},
]
25 changes: 25 additions & 0 deletions Package Control.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"installed_packages":
[
"CodeFormatter",
"CTags",
"DocBlockr",
"Emmet",
"Git",
"Gitignore",
"Goto Documentation",
"LiveStyle",
"PHP Companion",
"Phpcs",
"Sass",
"SCSS",
"SCSS Snippets",
"SideBarEnhancements",
"SideBarGit",
"SublimeCodeIntel",
"sublimelint",
"SyncedSideBar",
"Theme - Phoenix",
"Theme - Spacegray"
]
}
14 changes: 14 additions & 0 deletions Preferences.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_size": 14,
"ignored_packages":
[
"Vintage"
],
"phoenix_color_blue": true,
"phoenix_dirty_bottom_bar": true,
"phoenix_dirty_bottom_bar_red": true,
"phoenix_solid_current_tab": true,
"theme": "Phoenix Dark.sublime-theme",
"word_wrap": true
}
3 changes: 3 additions & 0 deletions Side Bar.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "setting no longer updated"
}
17 changes: 17 additions & 0 deletions endsemicolon.sublime-macro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"args":
{
"extend": false,
"to": "eol"
},
"command": "move_to"
},
{
"args":
{
"characters": ";"
},
"command": "insert"
}
]
1 change: 1 addition & 0 deletions linters/.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a4c0b528832a037ccc0c398c81157ba996cdfcc6
113 changes: 113 additions & 0 deletions linters/applescript.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
from lint import Linter
import json
import platform
import subprocess


def clean_output(args):
return '\n'.join([a.decode('utf8') for a in args if a])


def popen(*cmd):
p = subprocess.Popen(cmd,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
return clean_output(p.communicate())


lint_script = '''
import sys
from Foundation import NSAppleScript, NSConcreteValue, NSRange
import objc
import json
class CustomCodec(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, NSConcreteValue):
if obj.objCType() == NSRange.__typestr__:
r = obj.rangeValue()
return (r.location, r.length)
return json.JSONEncoder.default(self, obj)
def lint(code):
code = code.decode('utf8')
linter = NSAppleScript.alloc().initWithSource_(code)
errors = dict(linter.compileAndReturnError_(None)[1] or {})
objc.recycleAutoreleasePool()
return CustomCodec().encode(errors)
if __name__ == '__main__':
code = sys.stdin.read()
print lint(code)
'''


find_app_script = '''
import LaunchServices
import sys
code, ref, url = LaunchServices.LSFindApplicationForInfo(
LaunchServices.kLSUnknownCreator, None, sys.argv[1], None, None)
if url:
sys.stdout.write(url.path().encode('utf8'))
'''


app_name_cache = {}
def find_app(name):
if not name.endswith('.app'):
name += '.app'
if not name in app_name_cache:
app = popen('/usr/bin/python', '-c', find_app_script, name)
app_name_cache[name] = app
return app_name_cache[name]

APP_NAME_SEL = 'string.quoted.double.application-name.applescript'


class AppleScript(Linter):
@classmethod
def can_lint(cls, language):
if platform.system() != 'Darwin':
return
return 'AppleScript' in language

def lint(self):
tell_apps = [
(region, self.view.substr(region).strip('"'))
for region in self.view.find_by_selector(APP_NAME_SEL)
]
any_invalid = False
for region, name in tell_apps:
if not find_app(name):
any_invalid = True
start = region.a + 1
end = region.b - start - 1
line = self.code[:start].count('\n')
line_len = len(self.code.split('\n')[line])
offset = 0
if line:
start -= self.code[:start].rindex('\n') + 1

end = min(line_len - start, end)
self.highlight.range(line, start, end)
self.error(line, 'Could not find app named {}'.format(name))

if any_invalid:
return

out = self.communicate(('/usr/bin/python', '-c', lint_script), self.code)
out = out.replace('\u2019', '\'')
error = json.loads(out)
if error:
brief = error['NSAppleScriptErrorBriefMessage']
# message = error['NSAppleScriptErrorMessage']
start, end = error['NSAppleScriptErrorRange']

line = self.code[:start].count('\n')
offset = 0
if line:
offset = start - self.code[:start].rindex('\n')

self.highlight.range(line, offset, end - offset)
self.error(line, brief)
51 changes: 51 additions & 0 deletions linters/c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import os

from lint import Linter
from sublimelint.lint.util import find

def find_includes(filename):
includes = []
if filename:
parent = os.path.dirname(filename)
if not parent:
return includes

includes.append('-I' + parent)
inc = find(parent, 'include')
if inc:
includes.append('-I' + inc)

return includes

class C(Linter):
language = 'c'
cmd = ('clang',)
args = ('-xc', '-fsyntax-only', '-std=c99', '-Werror', '-pedantic')
regex = (
r'^<stdin>:(?P<line>\d+):(?P<col>\d+):'
r'(?:(?P<ranges>[{}0-9:\-]+):)?\s+'
r'(?P<error>.+)'
)
defaults = {
'cmd': cmd,
'args': args,
'include': [],
}

def run(self, cmd, code):
cmd = tuple(self.settings.get('cmd'),) or self.cmd
cmd += tuple(self.settings.get('args', []))
for include in self.settings.get('include', []):
cmd += ('-I{}'.format(include),)
cmd += ('-',) + tuple(find_includes(self.filename))
return super().communicate(cmd, code)

class CPP(C):
language = 'c++'
cmd = ('clang++',)
args = ('-xc++', '-fsyntax-only', '-std=c++11', '-Werror', '-pedantic')
defaults = {
'cmd': cmd,
'args': args,
'include': [],
}
6 changes: 6 additions & 0 deletions linters/coffee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from lint import Linter

class Coffee(Linter):
language = 'coffeescript'
cmd = ('coffee', '--compile', '--stdio')
regex = r'^[A-Za-z]+: (?P<error>.+) on line (?P<line>\d+)'
13 changes: 13 additions & 0 deletions linters/css.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from lint import Linter

class CSS(Linter):
language = 'css'
cmd = ('csslint',)
regex = (
r'^\d+: (?P<type>(error|warning)) at line (?P<line>\d+), col (?P<col>\d+)$\W'
r'^(?P<error>.*)$'
)
multiline = True

def run(self, cmd, code):
return self.tmpfile(cmd, code, suffix='.css')
69 changes: 69 additions & 0 deletions linters/eclim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import json
import os
import tempfile

from lint import Linter
from sublimelint.lint.util import find

class Eclim(Linter):
language = 'java'
cmd = ('eclim', '-command', 'java_src_update')
regex = r'.'

defaults = {
'disable': True,
}

def run(self, cmd, code):
project = find(os.path.dirname(self.filename), '.project', True)
if not project:
return

filename = self.filename.replace(project, '', 1).lstrip(os.sep)
project = os.path.basename(project)

# can't stdin or temp use file - hack time?
# this *could* become a tmp directory
# but I'd need to know all files to copy
# from the source project
tmp = tempfile.mktemp()
os.rename(self.filename, tmp)
# at least we get some inode protection on posix
inode = None

with open(self.filename, 'wb') as f:
f.write(code)
if os.name == 'posix':
inode = os.stat(self.filename).st_ino

try:
cmd = cmd + ('-p', project, '-f', filename, '-v')
output = self.communicate(cmd, '')
finally:
if inode is not None:
new_inode = os.stat(self.filename).st_ino
if new_inode != inode:
# they saved over our tmp file, bail
return output

os.unlink(self.filename)
os.rename(tmp, self.filename)

return output

def find_errors(self, output):
try:
obj = json.loads(output)
for item in obj:
# TODO: highlight warnings in a different color?
# warning = item['warning']
line, col = item['line']-1, item['column']-1
message = item['message']
yield True, line, col, message, None
except Exception:
error = 'eclim error'
if 'Connection refused' in output:
error += ' Connection Refused'
yield True, 0, None, error, None
# maybe do this on line one?
# yield {"eclim_exception": str(e)}
31 changes: 31 additions & 0 deletions linters/go.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
from lint import Linter

def find_files(root, ext):
root = root.rstrip(os.sep) + os.sep
ret = []
for base, dirs, names in os.walk(root):
for name in names:
if name.endswith(ext):
base = base.replace(root, '', 1)
ret.append(os.path.join(base, name))
return ret

class Golang(Linter):
language = 'go'
cmd = ('go', 'build', '-gcflags', '-e -N')
regex = r'.+?:(?P<line>\d+): (?P<error>.+)'

def run(self, cmd, code):
code = code.encode('utf8')
path = os.path.split(self.filename)[0]
if not self.filename or not path:
tools = self.popen(('go', 'tool')).communicate()[0].decode('utf8').split('\n')
for compiler in ('6g', '8g'):
if compiler in tools:
return self.tmpfile(('go', 'tool', compiler, '-e', '-o', os.devnull), code, suffix='.go')
else:
os.chdir(path)
files = find_files(path, '.go')
answer = self.tmpdir(cmd, files, code)
return answer
6 changes: 6 additions & 0 deletions linters/haml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from lint import Linter

class HAML(Linter):
language = 'ruby haml'
cmd = ('haml', '-c')
regex = r'^.*line (?P<line>\d+):\s*(?P<error>.+)$'
6 changes: 6 additions & 0 deletions linters/html.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from lint import Linter

class HTML(Linter):
language = 'html'
cmd = ('tidy', '-q', '-e', '-utf8')
regex = r'^line (?P<line>\d+) column (?P<col>\d+) - (Warning|Error)?\s*:?\s*(?P<error>.+)$'
Loading

0 comments on commit 0ef63d5

Please sign in to comment.