annotate .vimrc @ 12:4bb4daa9e3f1 development

Working with the new FileModifier
author luka
date Wed, 24 Apr 2024 19:52:35 -0400
parents cf9993c5c7df
children e577dac6c913 827efbf4d73c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
1 syntax on
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
2 set tabstop=2
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
3 set shiftwidth=2
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
4 set softtabstop=2
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
5 set autoindent
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
6 set smartindent
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
7 "set termguicolors
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
8 "set number
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
9 nnoremap <Leader>cc :set colorcolumn=80<cr>
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
10 nnoremap <Leader>ncc :set colorcolumn-=80<cr>
12
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
11 nnoremap <C-l> :ALECodeAction <cr>
2
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
12 set mouse=a
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
13
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
14 function! FixPhpFiles()
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
15 " Save the current cursor position
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
16 let save_cursor = getpos(".")
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
17
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
18 "Format the files
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
19 let command = 'php-cs-fixer fix .'
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
20 let output = system(command)
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
21 " Reload the file and restore the cursor position
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
22 execute 'edit!'
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
23 call setpos(".", save_cursor)
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
24 endfunction
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
25
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
26 nnoremap <leader>f :call FixPhpFiles()<CR>
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
27
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
28 " Committing commands
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
29 map <C-k> :wa<CR>:!hg addremove && hg commit <CR>
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
30
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
31 " Git commands, for now don't port to hg
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
32 " function! GitDiffCached()
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
33 " let files = system('git diff --cached --name-only')
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
34 "
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
35 " if v:shell_error
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
36 " echo "Error running git diff"
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
37 " return
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
38 " endif
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
39 "
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
40 " let filelist = split(files, "\n")
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
41 " let chosen_file = inputlist(filelist)
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
42 "
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
43 " if chosen_file != -1
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
44 " let cmd = 'tabnew ' . filelist[chosen_file]
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
45 " execute cmd
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
46 " endif
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
47 " endfunction
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
48 "
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
49 " execute "set <M-d>=\033d"
cf9993c5c7df Updated .vimrc for some helper commands.
luka
parents:
diff changeset
50 " map <M-d> :call GitDiffCached()<CR>
12
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
51 "
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
52 "
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
53 "
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
54 "
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
55
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
56
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
57 function! SendBufferToProgram()
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
58 " Create a temporary file
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
59 let temp_file = tempname()
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
60
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
61 " Write current buffer to the temporary file
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
62 exe "write! " . temp_file
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
63
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
64 " Send the content of the temporary file to your program
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
65 " Replace <your_program> with the actual command to run your program
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
66 let command = "cat " . temp_file . " | <your_program>"
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
67
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
68 " Execute the command
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
69 call system(command)
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
70
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
71 " Optionally, delete the temporary file if not needed
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
72 call delete(temp_file)
4bb4daa9e3f1 Working with the new FileModifier
luka
parents: 2
diff changeset
73 endfunction