diff options
Diffstat (limited to 'Common/nvim')
-rwxr-xr-x | Common/nvim/lua/helper_functions.lua | 41 | ||||
-rwxr-xr-x | Common/nvim/lua/plugins.lua | 13 | ||||
-rw-r--r-- | Common/nvim/spell/nb.utf-8.add | 1 | ||||
-rw-r--r-- | Common/nvim/spell/nb.utf-8.add.spl | bin | 0 -> 61 bytes |
4 files changed, 50 insertions, 5 deletions
diff --git a/Common/nvim/lua/helper_functions.lua b/Common/nvim/lua/helper_functions.lua index 81ad6ca..945473b 100755 --- a/Common/nvim/lua/helper_functions.lua +++ b/Common/nvim/lua/helper_functions.lua @@ -118,6 +118,47 @@ vim.api.nvim_create_user_command('A', auto, {bang=false, desc='Enable filetype p vim.api.nvim_create_user_command('RerunTermCommand', rerun_last_command_in_any_terminal, {bang=false, desc=''}) vim.api.nvim_set_keymap('n', '<F5>', ':lua rerun_last_command_in_any_terminal()<CR>', {noremap = true, silent = true}) +-- Look at history on range or line +vim.cmd [[ +function! ShowCommitDiff(commit) + " Extract the commit hash from the selected line (assuming it's the first word) + let commit_hash = split(a:commit)[0] + + tabnew + setlocal buftype=nofile + setlocal bufhidden=delete + + " Use 'read !command' to insert the output of the git show command into the buffer + execute 'read !git show ' . commit_hash + + setlocal nomodifiable + set filetype=gitcommit + normal! gg +endfunction + +function! GitHistoryForLine(start_line, end_line) + " Check if the range encompasses the entire file, which might indicate that no specific range was provided + if a:start_line == 1 && a:end_line == line('$') + " Default to the current line if it seems like the entire file is being selected + let l:start_line = line('.') + let l:end_line = l:start_line + else + let l:start_line = a:start_line + let l:end_line = a:end_line + endif + + let l:filepath = expand('%:p') + let l:git_cmd = 'git log -s --pretty=format:"%h %s (%an)" -L '.l:start_line.','.l:end_line.':"'.l:filepath.'"' + let l:options = '--delimiter " " --preview "git show {1}"' + call fzf#vim#grep(l:git_cmd, 1, {'options': l:options, 'sink': function('ShowCommitDiff')}, 0) +endfunction + +command! -range=% GitHistoryForLine call GitHistoryForLine(<line1>, <line2>) +nnoremap <leader><leader>s :GitHistoryForLine<CR> +vnoremap <leader><leader>s :'<,'>GitHistoryForLine<CR> +]] + + -- Close buffer without closing window --[[ vim.cmd [[ diff --git a/Common/nvim/lua/plugins.lua b/Common/nvim/lua/plugins.lua index d9ae65f..65b7d05 100755 --- a/Common/nvim/lua/plugins.lua +++ b/Common/nvim/lua/plugins.lua @@ -76,14 +76,17 @@ return require('packer').startup(function(use) -- fzf (Fuzzy finder for various things) use { 'junegunn/fzf.vim', - requires = { 'kyazdani42/nvim-web-devicons' }, + requires = { 'junegunn/fzf', 'kyazdani42/nvim-web-devicons' }, config = function() vim.cmd [[ let g:fzf_layout = { 'down': '40%' } + autocmd! FileType fzf + autocmd FileType fzf set laststatus=0 noshowmode noruler + \| autocmd BufLeave <buffer> set laststatus=2 showmode ruler ]] map("n", ";", ":Files<cr>", silentnoremap) map("n", "<leader>;", ":Rg<cr>", silentnoremap) - map("n", "<leader><leader>;", ":BLines<cr>", silentnoremap) + map("n", "<leader><leader>;", ":Lines<cr>", silentnoremap) end, } @@ -180,10 +183,10 @@ return require('packer').startup(function(use) }, }, { - path = '~/Nextcloud/wiki/M42', + path = '~/Nextcloud/1-Prosjekter/101-masteroppgave/101.02-quick-notes', syntax = 'markdown', ext = 'md', - name = 'M42', + name = 'P101', auto_toc = 1, nested_syntaxes = { python = 'python', @@ -191,7 +194,7 @@ return require('packer').startup(function(use) }, }, { - path = '~/Nextcloud/wiki/P01/', + path = '~/Nextcloud/', syntax = 'markdown', ext = 'md', name = 'P01', diff --git a/Common/nvim/spell/nb.utf-8.add b/Common/nvim/spell/nb.utf-8.add new file mode 100644 index 0000000..aab906d --- /dev/null +++ b/Common/nvim/spell/nb.utf-8.add @@ -0,0 +1 @@ +meldingsutveksling diff --git a/Common/nvim/spell/nb.utf-8.add.spl b/Common/nvim/spell/nb.utf-8.add.spl Binary files differnew file mode 100644 index 0000000..b8c156a --- /dev/null +++ b/Common/nvim/spell/nb.utf-8.add.spl |