##############################################################################
# User plugin space.

import sys
from os.path import expanduser, join
sys.path.append(join(expanduser('~'), '.vy'))
##############################################################################
# Functions used to load the plugins.
from vyapp.plugins import autoload, autocall, mapset
##############################################################################
# Install untwisted reactor into tkinter. 
# Plugins like ibash, spawn wouldn't work without this import.

from vyapp.plugins import untwisted
##############################################################################
# Example remaping keys.

# Use the function mapset to remap your keys. 
# The 'line-index' stands for the plugin namespace.
# The code below permits the code binded to <Control-q> in NORMAL mode
# to work in NORMAL mode when <Key-g> event happens.
# It may be interesting to call mapset close to the plugin
# imports It is not necessary to be here but it has to be set
# before the plugin is installed with autoload.

# mapset('line-index', {
# ('NORMAL', '<Control-q>'): (('NORMAL', '<Control-q>'), 
# ('NORMAL', '<Key-g>'))})

# Note: Plugin namepaces should follow the pattern
# plugin-name it means any '_' is replaced for '-'.

##############################################################################
# Basic core modes.

import vyapp.plugins.builtin_modes
autoload(vyapp.plugins.builtin_modes)

##############################################################################
# Extra/programming language modes.

import vyapp.plugins.python_mode
autoload(vyapp.plugins.python_mode)

import vyapp.plugins.golang_mode
autoload(vyapp.plugins.golang_mode)

import vyapp.plugins.html_mode
autoload(vyapp.plugins.html_mode)

import vyapp.plugins.c_mode
autoload(vyapp.plugins.c_mode)

import vyapp.plugins.javascript_mode
autoload(vyapp.plugins.javascript_mode)

import vyapp.plugins.cplusplus_mode
autoload(vyapp.plugins.cplusplus_mode)

##############################################################################
# Core plugins.

# Update statusbar cursor line/col.
import vyapp.plugins.cursor_status
autoload(vyapp.plugins.cursor_status)

# Update areavi filename on tabs, window title.
import vyapp.plugins.io_status
autoload(vyapp.plugins.io_status)

# Pinned modes.
import vyapp.plugins.mode_shortcut
autoload(vyapp.plugins.mode_shortcut)

# Used to associate ranges of text with 
# info/data.
import vyapp.plugins.assoc
autoload(vyapp.plugins.assoc)

# Used to set your AreaVi project attribute
# automatically based on .git, .svn, .hg dirs.
# Where ._ is used by vy to identify a root project.
# The project attribute is used by other plugins to perform
# useful operations related to development.
from vyapp.plugins.project import Project
Project.c_sentinels('.git', '.svn', '.hg', '._')
autocall(Project)

# Implement a keycommand to set the AreaVi.HOME
# directory.
from vyapp.plugins import home
autoload(home)

# Provide anchors for text.
import vyapp.plugins.anchors
autoload(vyapp.plugins.anchors)

# Implement keycommands to select special sequences of chars.
# Like sel from start/end.
import vyapp.plugins.data_sel
autoload(vyapp.plugins.data_sel)

# Implement keycommand to remove selection from chars.
import vyapp.plugins.clear_sel
autoload(vyapp.plugins.clear_sel)

# Quickly switch focus between tabs by
# using lazy search pattern.
import vyapp.plugins.tab_search
autoload(vyapp.plugins.tab_search)

# The word_search plugin.
import vyapp.plugins.word_search
autoload(vyapp.plugins.word_search)

# Shifting blocks of code.
import vyapp.plugins.shift
autoload(vyapp.plugins.shift)

# Used to quickly jump to the end/start of the file.
import vyapp.plugins.text_jumps
autoload(vyapp.plugins.text_jumps)

# Used to deal with panes.
import vyapp.plugins.splits
autoload(vyapp.plugins.splits)

# Used to deal with tabs.
import vyapp.plugins.tabs
autoload(vyapp.plugins.tabs)

# Implement keycommands to undo/redo operations.
import vyapp.plugins.undo
autoload(vyapp.plugins.undo)

# It implements keycomands to move the cursor up, down, left, right.
import vyapp.plugins.main_jumps
autoload(vyapp.plugins.main_jumps)

# The quick_search plugin implements incremental search.
# The matching regions can have their appearance customized with
# the QuickSearch.c_appearance method.
from vyapp.plugins.quick_search import QuickSearch
QuickSearch.c_appearance(background='yellow', foreground='black')
autocall(QuickSearch)

# Used to jump quickly to chars.
import vyapp.plugins.seek_symbol
autoload(vyapp.plugins.seek_symbol)

# This plugin implements keycommands to scroll lines.
import vyapp.plugins.line_scroll
autoload(vyapp.plugins.line_scroll)

# This plugin implements keycommands to scroll pages.
import vyapp.plugins.page_scroll
autoload(vyapp.plugins.page_scroll)

# Used to select the text between pairs of (), [], {} when 
# the cursor is placed over one of the (), {}, [].
import vyapp.plugins.pair_sel
autoload(vyapp.plugins.pair_sel)

# Implement keycommands to insert a line up/down.
import vyapp.plugins.line_feed
autoload(vyapp.plugins.line_feed)

# Used to put the cursor on a given line.col.
import vyapp.plugins.line_index
autoload(vyapp.plugins.line_index)

# Implement keycommands to control where data is written 
# to sys.stdout is going to be echoed.
import vyapp.plugins.outputs
autoload(vyapp.plugins.outputs)

# Used to execute python code on the fly, things like python functions
# to substitute text, format stuff etc, load plugins.
import vyapp.plugins.cmd
autoload(vyapp.plugins.cmd)

# Used to search for text/format text with regex.
# The class attribute TAGCONF holds default styling 
# for the tag '(CATCHED)' That's added on matching patterns.
from vyapp.plugins.find import Find
Find.c_appearance(background='green', foreground='white')
autocall(Find)

# It implements ways of opening/saving files.
import vyapp.plugins.io
autoload(vyapp.plugins.io)

# Implement key-commands to delete selected text, lines, chars.
import vyapp.plugins.data_del
autoload(vyapp.plugins.data_del)

# Used to highlight pairs of character like () {} [].
# It is useful when playing with lisp things.
import vyapp.plugins.match_sym_pair
autoload(vyapp.plugins.match_sym_pair)

# Used to complete words when Control-q is issued on insert mode.
import vyapp.plugins.word_completion
autoload(vyapp.plugins.word_completion)

# Implements key-commands to copy/cut/paste text.
import vyapp.plugins.clipboard
autoload(vyapp.plugins.clipboard)

# Used to remember an important position of the 
# text and quickly switch back to it.
import vyapp.plugins.quick_jumps
autoload(vyapp.plugins.quick_jumps)

# This plugin is used to place the cursor over 
# the next occurrence of the symbols passed to 
# symbol_jumps install function.
import vyapp.plugins.symbol_jumps
autoload(vyapp.plugins.symbol_jumps, 
('(', ')', '.', '[', ']', '{', '}', ',', ':', ';', "'", '"'))

# text_spots plugin is used to mark lines then quickly
# go to the previous or next mark.
import vyapp.plugins.text_spots
autoload(vyapp.plugins.text_spots)

# range_sel plugin implemets selection commannds.
import vyapp.plugins.range_sel
autoload(vyapp.plugins.range_sel)

# block_selection plugin implemets selection commannds.
import vyapp.plugins.block_sel
autoload(vyapp.plugins.block_sel)

##############################################################################
# Extra plugins.

# Used to perform searches in pre defined or git, svn, hg projects.
# Use Sniper.c_dirs to set the folders where you usually search for data.
# The Sniper.c_path is used to set your ag path.
# from vyapp.plugins.sniper import Sniper
# Sniper.c_dirs('/home/user/projects')
# Sniper.c_path('ag')
# autocall(Sniper)

# Uncomment and set the path to silver search in case 
# it is not available in the environment.
# from vyapp.plugins.fstmt import Fstmt
# Fstmt.c_path('ag')
# autocall(Fstmt)

# A wrap around unix locate command.
# from vyapp.plugins import fsniffer
# autoload(fsniffer)

# The ysnippet plugin.
import vyapp.plugins.ysnippet
autoload(vyapp.plugins.ysnippet)

# The mc filenamanager.
# Configure your color scheme with 
# Mc.c_appearance method..
# from vyapp.plugins.mc import Mc
# Mc.c_appearance(dir={'foreground': 'red'}, 
# file={'foreground': 'yellow'})
# autocall(Mc)

# Drop/Read data from a bash process.
# import vyapp.plugins.ibash
# autoload(vyapp.plugins.ibash)

# Python syntax checker through pyflakes.
# Use the classmethod c_path to set pyflakes path.
from vyapp.plugins.snakerr import PythonChecker
PythonChecker.c_path('pyflakes')
autocall(PythonChecker)

# Python analysis through vulture.
from vyapp.plugins import deadcode
# The path to vulture executable. No need to set it
# if vulture is on your env path.
# deadcode.PythonAnalysis.PATH = 'vulture'
autoload(deadcode)

# Download html from the clipboard url in the active AreaVi
# instance.
import vyapp.plugins.urls
autoload(vyapp.plugins.urls)

# This plugin implements a keycommand to quickly load the user vyrc file
# into the current AreaVi instance.
import vyapp.plugins.editrc
autoload(vyapp.plugins.editrc)

# Python auto completion plugin using jedi.
import vyapp.plugins.jedi
autoload(vyapp.plugins.jedi)

# You may need to setup tidy path here depending on your installation.
# But if tidy is available in the environment then no need to uncomment this line.
# from  vyapp.plugins import tidy
# tidy.HtmlChecker.PATH = '/path/to/tidy'
# autoload(tidy)

# Auto completion using ycmd.
# from vyapp.plugins.ycmd import client
# client.YcmdCompletion.setup('/path/to/ycmd')
# autoload(client)

# Refactorying tools.
import vyapp.plugins.rope
autoload(vyapp.plugins.rope)

# from vyapp.plugins.ternjs.completer import JavascriptCompletion 
# JavascriptCompletion.PATH = 'tern'
# JavascriptCompletion.PORT = 1234
# autocall(JavascriptCompletion)

# Golang auto completion with gocode engine. Don't mix it
# with ycmd plugin.
# from vyapp.plugins.gohints import GolangCompletion
# GolangCompletion.PATH ='/path/to/gocode'
# autocall(GolangCompletion)

# Used to insert tab, spaces.
# The default size/char in case the file has no 
# extension or it is not specified it is ''. When there is no '':(size, char)
# then it uses (4, ' ') as indentation.
from vyapp.plugins import spacing
spacing.Tab.set_scheme({
'.rb': (2, ' '),
'.c' : (4, ' '),
'.cpp' : (4, ' '),
'.java' : (4, ' '),
'.go':(1, '\t'),
'.py': (4, ' '),
'':(4, ' '), })
autoload(spacing)

# This plugin implements keys to comment pieces of text inside 
# programming language files.
import vyapp.plugins.inline_comment
autoload(vyapp.plugins.inline_comment)

# Used to debug python applications. The python argument 
# specifies the interpreter path.
# import vyapp.plugins.pdb.unix_platform
# autoload(vyapp.plugins.pdb.unix_platform, python='python2')

# import vyapp.plugins.pdb.cross_platform
# autoload(vyapp.plugins.pdb.cross_platform, python='python2')

# This plugin highlights links when files are opened.
import vyapp.plugins.hlink
autoload(vyapp.plugins.hlink)

# It implementes some features like a key command
# to copy to the clipboard the name of the actual opened file.
import vyapp.plugins.clip_path
autoload(vyapp.plugins.clip_path)

##############################################################################
# Syntax plugin is used to highlight code.
# It uses python pygments styles to highlight code :)
# Check out more pygments styles.
# Note: When uncommenting a theme dont forget to comment the previously used one.
import vyapp.plugins.syntax.spider

# from pygments.styles.emacs import EmacsStyle
# autoload(vyapp.plugins.syntax.spider, EmacsStyle)

# from pygments.styles.murphy import MurphyStyle
# autoload(vyapp.plugins.syntax.spider, MurphyStyle)

# from pygments.styles.abap import AbapStyle
# autoload(vyapp.plugins.syntax.spider, AbapStyle)

# from pygments.styles.borland import BorlandStyle
# autoload(vyapp.plugins.syntax.spider, BorlandStyle)

# from pygments.styles.fruity import FruityStyle
# autoload(vyapp.plugins.syntax.spider, FruityStyle)

# from pygments.styles.colorful import ColorfulStyle
# autoload(vyapp.plugins.syntax.spider, ColorfulStyle)

# from pygments.styles.tango import TangoStyle
# autoload(vyapp.plugins.syntax.spider, TangoStyle)

# from pygments.styles.trac import TracStyle
# autoload(vyapp.plugins.syntax.spider, TracStyle)

# from pygments.styles.igor import IgorStyle
# autoload(vyapp.plugins.syntax.spider, IgorStyle)

# from pygments.styles.paraiso_dark import ParaisoDarkStyle
# autoload(vyapp.plugins.syntax.spider, ParaisoDarkStyle)

# from pygments.styles.vim import VimStyle
# autoload(vyapp.plugins.syntax.spider, VimStyle)

from vyapp.plugins.syntax.styles.vy import VyStyle
autoload(vyapp.plugins.syntax.spider, VyStyle)

##############################################################################
# Core command plugins.

# Implement commands for common key-commands.
import vyapp.plugins.cmd_utils

# Plugin tools.
import vyapp.plugins.plugin_tools

# Saving, opening files from vy python command line.
import vyapp.plugins.iocmd

# Find, replace, highlight patterns from vy python command line.
import vyapp.plugins.cmd_search

# Strip spaces from the beginning of lines.
import vyapp.plugins.line_strips

##############################################################################
# Extra command plugins.

# Implement lower and upper functions.
from vyapp.plugins import caps

# Count words.
import vyapp.plugins.count_words

# Managing file encodings.
import vyapp.plugins.codec

# Spawning processes.
# import vyapp.plugins.spawn.unix_platform

# Spawning processes cross_platform.
# import vyapp.plugins.spawn.cross_platform

##############################################################################
# Setup area settings, like default background, foreground, font style etc.

# Note: Plugins like syntax highlighting will define AreaVi instance settings 
# like background and foreground. # It is possible to override these settings 
# by uncommenting foreground and background arguments below. 

# Handles like setup are the last ones.

def setup(area):
    area.config(blockcursor=True, insertbackground='red', 
                # background='black', foreground='yellow', 
                font=('Monospace', 8, 'bold'), undo=True)

autocall(setup) 
