##############################################################################
# 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

##############################################################################
# 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.delta_mode
autoload(vyapp.plugins.delta_mode)


import vyapp.plugins.gamma_mode
autoload(vyapp.plugins.gamma_mode)


import vyapp.plugins.beta_mode
autoload(vyapp.plugins.beta_mode)


import vyapp.plugins.alpha_mode
autoload(vyapp.plugins.alpha_mode)


import vyapp.plugins.insert_mode
autoload(vyapp.plugins.insert_mode)


import vyapp.plugins.normal_mode
autoload(vyapp.plugins.normal_mode)


import vyapp.plugins.cursor_status
autoload(vyapp.plugins.cursor_status)


import vyapp.plugins.mode_status
autoload(vyapp.plugins.mode_status)


import vyapp.plugins.io_status
autoload(vyapp.plugins.io_status)
##############################################################################
# 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)

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

# 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.
from vyapp.plugins.project import Project
Project.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.
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, width=2, char=' ')


# Used to quickly jump to the end/start of the cursor line.
import vyapp.plugins.line_jumps
autoload(vyapp.plugins.line_jumps)


# 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 select text from the cursor position 
# to the start/end of the file.
import vyapp.plugins.text_sel
autoload(vyapp.plugins.text_sel)


# Default events for 'Text'.
import vyapp.plugins.default
autoload(vyapp.plugins.default)


# 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.
from vyapp.plugins import quick_search
# quick_search.QuickSearch.TAGCONF = {'(SEARCH_MATCH)' : {
# 'background':'yellow', 'foreground':'black'}}
autoload(quick_search)


# 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)


# This plugin implements keycommands to jump quickly
# to the next/previous word from the cursor position.
import vyapp.plugins.word_jumps
autoload(vyapp.plugins.word_jumps)


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


# Implement a keycomand to select/unselect a line.
import vyapp.plugins.line_sel
autoload(vyapp.plugins.line_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 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 import find
# find.Find.TAGCONF = { '(CATCHED)': {
# 'background':'green', 'foreground':'white'}}
autoload(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.

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


# 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.python_completion
autoload(vyapp.plugins.python_completion)


# Used to insert tab, spaces.
from vyapp.plugins import spacing
spacing.Tab.SCHEME = {
'.rb': (2, ' '),
'.c' : (4, ' '),
'.cpp' : (4, ' '),
'.java' : (4, ' '),
'.go':(4, ' '),
'.py': (4, ' ')}

spacing.Tab.DEFAULT_SIZE = 4
spacing.Tab.DEFAULT_CHAR = ' '
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) 








