1
0
Fork 0

Updates logic for running file in normal mode and adds a variable for remapping the plugin's leder key

This commit is contained in:
sloum 2022-05-26 21:22:44 +00:00
parent 99b18dc3ac
commit bfe3f24710
2 changed files with 29 additions and 6 deletions

View File

@ -20,6 +20,16 @@ The plugin also adds a few functions/mappings:
- Typing `sp` while in normal or visual mode will move the cursor to a matching parenthesis (if you are on a parenthesis)
- This is just a remap of `%`, but makes it so you don't have to use the shift key (a presonal preference)
In the above mappings `s` is used as a leader key, which is the default set by the plugin. If you would like to override this you can add something like the following to your `.vimrc`:
``` vimscript
" Map the slope leader to `L`
" Then run the file by typing `Lr`
" in normal mode, for example
let g:slope_leader="L"
```
## Installation
```sh

View File

@ -13,7 +13,11 @@ setlocal expandtab
" Sets the local leader to 's' for use in
" mappings within the plugin/buffer
let maplocalleader="s"
if !exists("g:slope_leader")
let g:slope_leader="s"
endif
let maplocalleader=g:slope_leader
if !exists("g:slope_command")
let g:slope_command = "slope"
@ -24,12 +28,21 @@ endif
" to something else
function! RunSlopeFile()
silent !clear
execute "!" . g:slope_command . " " . bufname("%")
let topline = line("w0")
let botline = line("w$")
let lines = getline(topline, botline)
if len(lines) == 0
return ''
endif
let lines[-1] = lines[-1][: column_end - 2]
let lines[0] = lines[0][column_start - 1:]
silent !clear
execute "!" . g:slope_command . " -run \'" . join(lines, "") . "\'"
endfunction
function! RunVisualSelection()
let save_modified = g:modified
let g:modified = false
let save_modified = g:modified
let g:modified = false
let [line_start, column_start] = getpos("'<")[1:2]
let [line_end, column_end] = getpos("'>")[1:2]
let lines = getline(line_start, line_end)
@ -38,8 +51,8 @@ function! RunVisualSelection()
endif
let lines[-1] = lines[-1][: column_end - 2]
let lines[0] = lines[0][column_start - 1:]
silent !clear
execute "!" . g:slope_command . " -run \'" . join(lines, "") . "\'"
silent !clear
execute "!" . g:slope_command . " -run \'" . join(lines, "") . "\'"
endfunction
" map sk and sj to find the next or prev '(' across lines