~reykjalin/qode-kakoune

a91fe1af2adbdece7c63580de4a7663428c08bdb — Kristófer Reykjalín Þorláksson 4 years ago f5ed27e
Fix indentation
1 files changed, 120 insertions(+), 120 deletions(-)

M index.js
M index.js => index.js +120 -120
@@ 3,8 3,8 @@
const jayson = require( 'jayson' );

const modes = {
    insert: 'Insert',
    normal: 'Normal',
	insert: 'Insert',
	normal: 'Normal',
};

let currentMode = modes.normal;


@@ 19,135 19,135 @@ const hasOnlyCtrlMod = modifiers => {

const server = jayson.server( {
	configuration: function( args, callback ) {
    		callback( null, {
        		multipleSelections: true,
        	} );
		callback( null, {
			multipleSelections: true,
		} );
	},
	keys: function( args, callback ) {
    		const { key, modifiers } = args;
		const { key, modifiers } = args;
		console.error( args );
		console.error( key );
		console.error( modifiers );

		if ( modes.insert === currentMode ) {
    			if ( '\u001b' === args[ 'key' ] ) {
                		currentMode = modes.normal;
                		callback( null, [ 'normal_mode' ] );
    			} else {
                		callback( null, [ 'insert_key' ] );
    			}
    			return;
			if ( '\u001b' === args[ 'key' ] ) {
				currentMode = modes.normal;
				callback( null, [ 'normal_mode' ] );
			} else {
				callback( null, [ 'insert_key' ] );
			}
			return;
		}
    		switch( key ) {
        	case 'i':
        		if ( hasOnlyShiftMod( modifiers) ) {
            			callback( null, [ 'move_vc_home', 'insert_mode' ] );
        		} else {
                		currentMode = modes.insert;
                		callback( null, [ 'move_selection_start', 'insert_mode' ] );
        		}
            		currentMode = modes.insert;
        		break;
        	case 'a':
        		if ( hasOnlyShiftMod( modifiers) ) {
            			callback( null, [ 'move_line_end', 'insert_mode' ] );
        		} else {
                		callback( null, [ 'move_selection_end', 'insert_mode' ] );
        		}
            		currentMode = modes.insert;
        		break;
        	case 'o':
        		if ( hasOnlyShiftMod( modifiers ) ) {
            			callback( null, [ 'move_home', 'insert_new_line', 'move_line_up', 'insert_mode' ] );
        		} else {
            			callback( null, [ 'move_line_end', 'insert_new_line', 'insert_mode' ] );
        		}
            		currentMode = modes.insert;
        		break;
        	case '<left>':
    		case 'h':
    			if ( hasOnlyShiftMod( modifiers ) ) {
        			callback( null, [ 'extend_char_left' ] );
    			} else {
        			callback( null, [ 'move_char_left' ] );
    			}
    			break;
        	case '<up>':
    		case 'j':
    			if ( hasOnlyShiftMod( modifiers ) ) {
        			callback( null, [ 'extend_line_down' ] );
    			} else {
        			callback( null, [ 'move_line_down' ] );
    			}
    			break;
        	case '<down>':
    		case 'k':
    			if ( hasOnlyShiftMod( modifiers ) ) {
        			callback( null, [ 'extend_line_up' ] );
    			} else {
        			callback( null, [ 'move_line_up' ] );
    			}
    			break;
        	case '<right>':
    		case 'l':
    			if ( hasOnlyShiftMod( modifiers ) ) {
        			callback( null, [ 'extend_char_right' ] );
    			} else {
        			callback( null, [ 'move_char_right' ] );
    			}
    			break;
    		case 'w':
    			if ( ! hasOnlyShiftMod( modifiers ) ) {
        			callback( null, [ 'clear_selection', 'extend_word_right' ] );
    			} else {
        			callback( null, [ 'extend_word_right' ] );
    			}
    			break;
    		case 'b':
    			if ( ! hasOnlyShiftMod( modifiers ) ) {
        			callback( null, [ 'clear_selection', 'extend_word_left' ] );
    			} else {
        			callback( null, [ 'extend_word_left' ] );
    			}
    			break;
    		case 'x':
    			if ( hasOnlyShiftMod( modifiers ) ) {
        			callback( null, [ 'extend_line_down', 'extend_line_end' ] );
    			} else {
        			callback( null, [ 'move_home', 'extend_line_end' ] );
    			}
    			break;
		switch( key ) {
		case 'i':
			if ( hasOnlyShiftMod( modifiers) ) {
				callback( null, [ 'move_vc_home', 'insert_mode' ] );
			} else {
				currentMode = modes.insert;
				callback( null, [ 'move_selection_start', 'insert_mode' ] );
			}
			currentMode = modes.insert;
			break;
		case 'a':
			if ( hasOnlyShiftMod( modifiers) ) {
				callback( null, [ 'move_line_end', 'insert_mode' ] );
			} else {
				callback( null, [ 'move_selection_end', 'insert_mode' ] );
			}
			currentMode = modes.insert;
			break;
		case 'o':
			if ( hasOnlyShiftMod( modifiers ) ) {
				callback( null, [ 'move_home', 'insert_new_line', 'move_line_up', 'insert_mode' ] );
			} else {
				callback( null, [ 'move_line_end', 'insert_new_line', 'insert_mode' ] );
			}
			currentMode = modes.insert;
			break;
		case '<left>':
		case 'h':
			if ( hasOnlyShiftMod( modifiers ) ) {
				callback( null, [ 'extend_char_left' ] );
			} else {
				callback( null, [ 'move_char_left' ] );
			}
			break;
		case '<up>':
		case 'j':
			if ( hasOnlyShiftMod( modifiers ) ) {
				callback( null, [ 'extend_line_down' ] );
			} else {
				callback( null, [ 'move_line_down' ] );
			}
			break;
		case '<down>':
		case 'k':
			if ( hasOnlyShiftMod( modifiers ) ) {
				callback( null, [ 'extend_line_up' ] );
			} else {
				callback( null, [ 'move_line_up' ] );
			}
			break;
		case '<right>':
		case 'l':
			if ( hasOnlyShiftMod( modifiers ) ) {
				callback( null, [ 'extend_char_right' ] );
			} else {
				callback( null, [ 'move_char_right' ] );
			}
			break;
		case 'w':
			if ( ! hasOnlyShiftMod( modifiers ) ) {
				callback( null, [ 'clear_selection', 'extend_word_right' ] );
			} else {
				callback( null, [ 'extend_word_right' ] );
			}
			break;
		case 'b':
			if ( ! hasOnlyShiftMod( modifiers ) ) {
				callback( null, [ 'clear_selection', 'extend_word_left' ] );
			} else {
				callback( null, [ 'extend_word_left' ] );
			}
			break;
		case 'x':
			if ( hasOnlyShiftMod( modifiers ) ) {
				callback( null, [ 'extend_line_down', 'extend_line_end' ] );
			} else {
				callback( null, [ 'move_home', 'extend_line_end' ] );
			}
			break;
		case '%':
			callback( null, [ 'select_all' ] );
			break;
    		case 'd':
    			if ( hasOnlyCtrlMod( modifiers ) ) {
        			callback( null, [ 'scroll_page_down' ] );
    			} else {
        			callback( null, [ 'delete_selection' ] );
    			}
    			break;
    		case 'u':
    			if ( hasOnlyCtrlMod( modifiers ) ) {
        			callback( null, [ 'scroll_page_up' ] );
    			} else if ( hasOnlyShiftMod( modifiers ) ) {
        			callback( null, [ 'redo' ] );
    			} else {
        			callback( null, [ 'undo' ] );
    			}
    			break;
    		case 'c':
    			callback( null, [ 'delete_selection', 'insert_mode' ] );
            		currentMode = modes.insert;
    			break;
    		case 'y':
    			callback( null, [ 'copy_selection' ] );
    			break;
    		case 'p':
    			callback( null, [ 'paste' ] );
    			break;
    		default:
    			callback( null, String.fromCharCode( key ) );
		case 'd':
			if ( hasOnlyCtrlMod( modifiers ) ) {
				callback( null, [ 'scroll_page_down' ] );
			} else {
				callback( null, [ 'delete_selection' ] );
			}
			break;
		case 'u':
			if ( hasOnlyCtrlMod( modifiers ) ) {
				callback( null, [ 'scroll_page_up' ] );
			} else if ( hasOnlyShiftMod( modifiers ) ) {
				callback( null, [ 'redo' ] );
			} else {
				callback( null, [ 'undo' ] );
			}
			break;
		case 'c':
			callback( null, [ 'delete_selection', 'insert_mode' ] );
			currentMode = modes.insert;
			break;
		case 'y':
			callback( null, [ 'copy_selection' ] );
			break;
		case 'p':
			callback( null, [ 'paste' ] );
			break;
		default:
			callback( null, String.fromCharCode( key ) );
		}
	}
} );