-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from sbulav/feat-nvim-07
Feat nvim 07
- Loading branch information
Showing
8 changed files
with
255 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
" https://gist.github.com/romainl/56f0c28ef953ffc157f36cc495947ab3 | ||
" Execute grep in a subshell to avoid annoying confirmation screens | ||
function! Grep(args) | ||
let args = split(a:args, ' ') | ||
return system(join([&grepprg, shellescape(args[0]), len(args) > 1 ? join(args[1:-1], ' ') : ''], ' ')) | ||
" Execset grepprg=ag\ --vimgrep | ||
function! Grep(...) | ||
return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' ')) | ||
endfunction | ||
|
||
" Command to populate quickfix with Grep function results | ||
command! -nargs=+ -complete=file_in_path -bar Grep cgetexpr Grep(<q-args>) | ||
command! -nargs=+ -complete=file_in_path -bar LGrep lgetexpr Grep(<q-args>) | ||
command! -nargs=+ -complete=file_in_path -bar Grep cgetexpr Grep(<f-args>) | ||
command! -nargs=+ -complete=file_in_path -bar LGrep lgetexpr Grep(<f-args>) | ||
|
||
cnoreabbrev <expr> grep (getcmdtype() ==# ':' && getcmdline() ==# 'grep') ? 'Grep' : 'grep' | ||
cnoreabbrev <expr> lgrep (getcmdtype() ==# ':' && getcmdline() ==# 'lgrep') ? 'LGrep' : 'lgrep' | ||
|
||
" Open quickfix automatically if there are valid entries | ||
augroup quickfix | ||
autocmd! | ||
autocmd QuickFixCmdPost cgetexpr cwindow | ||
autocmd QuickFixCmdPost lgetexpr lwindow | ||
augroup END | ||
autocmd! | ||
autocmd QuickFixCmdPost cgetexpr cwindow | ||
autocmd QuickFixCmdPost lgetexpr lwindow | ||
augroup ENDute grep in a subshell to avoid annoying confirmation screens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,47 @@ | ||
local autocmds = { | ||
no_cursorline_in_insert_mode = { | ||
{ "InsertLeave,WinEnter", "*", "set cursorline" }, | ||
{ "InsertEnter,WinLeave", "*", "set nocursorline" }, | ||
}, | ||
hl_yank = { | ||
{ "TextYankPost", "*", 'lua vim.highlight.on_yank{higroup="IncSearch", timeout=1500, on_visual=true}' }, | ||
}, | ||
restore_curpos = { | ||
{ | ||
"BufReadPost", | ||
"*", | ||
[[ | ||
if line("'\"") >= 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif | ||
]], | ||
}, | ||
}, | ||
add_filetypes = { | ||
{ "BufWritePre", "*enkinsfile*", "lua require'jenkinsfile_linter'.validate()" }, | ||
}, | ||
} | ||
local utils = require "utils" | ||
|
||
require("utils").nvim_create_augroups(autocmds) | ||
vim.api.nvim_create_augroup("Highlight", { clear = true }) | ||
vim.api.nvim_create_autocmd("TextYankPost", { | ||
command = "silent! lua vim.highlight.on_yank({higroup='IncSearch', timeout=1500, on_visual = true})", | ||
group = "Highlight", | ||
desc = "Highlight yanked text", | ||
}) | ||
|
||
vim.api.nvim_create_augroup("CursorInsertMode", { clear = true }) | ||
vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, { | ||
callback = function() | ||
vim.opt.cursorline = true | ||
end, | ||
group = "CursorInsertMode", | ||
desc = "Enable cursorline in normal mode", | ||
}) | ||
vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, { | ||
callback = function() | ||
vim.opt.cursorline = false | ||
end, | ||
group = "CursorInsertMode", | ||
desc = "Disable cursorline on insert", | ||
}) | ||
|
||
vim.api.nvim_create_augroup("RestoreCursorPosition", { clear = true }) | ||
vim.api.nvim_create_autocmd("BufReadPost", { | ||
callback = function() | ||
-- TODO?: filetype/buftype exclude | ||
local row, col = unpack(vim.api.nvim_buf_get_mark(0, '"')) | ||
if row > 0 and row <= vim.api.nvim_buf_line_count(0) then | ||
vim.api.nvim_win_set_cursor(0, { row, col }) | ||
end | ||
end, | ||
desc = "Return to last known cursor position", | ||
group = "RestoreCursorPosition", | ||
}) | ||
vim.api.nvim_create_augroup("ValidateJenkinsfiles", { clear = true }) | ||
vim.api.nvim_create_autocmd("BufWritePre", { | ||
callback = function() | ||
utils.info("Validating Jenkinsfile", "LSP") | ||
require("jenkinsfile_linter").validate() | ||
end, | ||
group = "ValidateJenkinsfiles", | ||
desc = "Validate Jenkins files on save", | ||
pattern = "*enkinsfile*", | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.