Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions dots/dot-config/nvim/copy_matches.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
" Plugin to copy matches (search hits which may be multiline).
" Version 2012-05-03 from http://vim.wikia.com/wiki/VimTip478
"
" :CopyMatches copy matches to clipboard (each match has newline added)
" :CopyMatches x copy matches to register x
" :CopyMatches X append matches to register x
" :CopyMatches - display matches in a scratch buffer (does not copy)
" :CopyMatches pat (after any of above options) use 'pat' as search pattern
" :CopyMatches! (with any of above options) insert line numbers
" Same options work with the :CopyLines command (which copies whole lines).

" Jump to first scratch window visible in current tab, or create it.
" This is useful to accumulate results from successive operations.
" Global function that can be called from other scripts.
function! GoScratch()
let done = 0
for i in range(1, winnr('$'))
execute i . 'wincmd w'
if &buftype == 'nofile'
let done = 1
break
endif
endfor
if !done
new
setlocal buftype=nofile bufhidden=hide noswapfile
endif
endfunction

" Append match, with line number as prefix if wanted.
function! s:Matcher(hits, match, linenums, subline)
if !empty(a:match)
let prefix = a:linenums ? printf('%3d ', a:subline) : ''
call add(a:hits, prefix . a:match)
endif
return a:match
endfunction

" Append line numbers for lines in match to given list.
function! s:MatchLineNums(numlist, match)
let newlinecount = len(substitute(a:match, '\n\@!.', '', 'g'))
if a:match =~ "\n$"
let newlinecount -= 1 " do not copy next line after newline
endif
call extend(a:numlist, range(line('.'), line('.') + newlinecount))
return a:match
endfunction

" Return list of matches for given pattern in given range.
" If 'wholelines' is 1, whole lines containing a match are returned.
" This works with multiline matches.
" Work on a copy of buffer so unforeseen problems don't change it.
" Global function that can be called from other scripts.
function! GetMatches(line1, line2, pattern, wholelines, linenums)
let savelz = &lazyredraw
set lazyredraw
let lines = getline(1, line('$'))
new
setlocal buftype=nofile bufhidden=delete noswapfile
silent put =lines
1d
let hits = []
let sub = a:line1 . ',' . a:line2 . 's/' . escape(a:pattern, '/')
if a:wholelines
let numlist = [] " numbers of lines containing a match
let rep = '/\=s:MatchLineNums(numlist, submatch(0))/e'
else
let rep = '/\=s:Matcher(hits, submatch(0), a:linenums, line("."))/e'
endif
silent execute sub . rep . (&gdefault ? '' : 'g')
close
if a:wholelines
let last = 0 " number of last copied line, to skip duplicates
for lnum in numlist
if lnum > last
let last = lnum
let prefix = a:linenums ? printf('%3d ', lnum) : ''
call add(hits, prefix . getline(lnum))
endif
endfor
endif
let &lazyredraw = savelz
return hits
endfunction

" Copy search matches to a register or a scratch buffer.
" If 'wholelines' is 1, whole lines containing a match are returned.
" Works with multiline matches. Works with a range (default is whole file).
" Search pattern is given in argument, or is the last-used search pattern.
function! s:CopyMatches(bang, line1, line2, args, wholelines)
let l = matchlist(a:args, '^\%(\([a-zA-Z"*+-]\)\%($\|\s\+\)\)\?\(.*\)')
let reg = empty(l[1]) ? '+' : l[1]
let pattern = empty(l[2]) ? @/ : l[2]
let hits = GetMatches(a:line1, a:line2, pattern, a:wholelines, a:bang)
let msg = 'No non-empty matches'
if !empty(hits)
if reg == '-'
call GoScratch()
normal! G0m'
silent put =hits
" Jump to first line of hits and scroll to middle.
''+1normal! zz
else
execute 'let @' . reg . ' = join(hits, "\n") . "\n"'
endif
let msg = 'Number of matches: ' . len(hits)
endif
redraw " so message is seen
echo msg
endfunction
command! -bang -nargs=? -range=% CopyMatches call s:CopyMatches(<bang>0, <line1>, <line2>, <q-args>, 0)
command! -bang -nargs=? -range=% CopyLines call s:CopyMatches(<bang>0, <line1>, <line2>, <q-args>, 1)
9 changes: 6 additions & 3 deletions dots/dot-config/nvim/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Plug 'dense-analysis/ale'
Plug 'jose-elias-alvarez/null-ls.nvim'
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.1' }
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.2' }
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim'
Expand All @@ -39,7 +39,7 @@ Plug 'nvim-treesitter/nvim-treesitter-textobjects'
Plug 'lewis6991/gitsigns.nvim'
Plug 'epwalsh/obsidian.nvim'
Plug 'junegunn/vim-easy-align'
Plug 'preservim/nerdtree'
Plug 'scrooloose/nerdtree'

Plug 'github/copilot.vim'
if has('nvim')
Expand All @@ -53,6 +53,7 @@ endif
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'

Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
Plug 'lervag/vimtex'

" golang
Expand Down Expand Up @@ -340,7 +341,9 @@ require("lsp")
require("completion")
require("treesitter")
require("nullls")
--require("metals_config")
require("metals_config")
require("copilot-config")

require("telescope_config")
require("copilot-config")
require("latex")
Expand Down
4 changes: 2 additions & 2 deletions dots/dot-config/nvim/lua/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)

require('mason').setup()

local servers = { 'pyright', 'tsserver', 'lua-language-servers' }
local servers = { 'pyright', 'tsserver', 'lua_ls', 'yaml-language-server' }

require('mason-lspconfig').setup {
ensure_installed = servers,
Expand All @@ -46,7 +46,7 @@ local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, 'lua/?.lua')
table.insert(runtime_path, 'lua/?/init.lua')

require('lspconfig').lua.setup {
require('lspconfig').lua_ls.setup {
on_attach = on_attach,
capabilities = capabilities,
settings = {
Expand Down
9 changes: 8 additions & 1 deletion dots/dot-config/nvim/lua/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,11 @@ local function switch_case()
end
end

return { switch_case = switch_case }
local function ConvertToSnakeCase()
local word = vim.fn.expand("<cword>") -- Get the current word under the cursor
local snake_case_word = string.gsub(word, "(%w)(%u)", "%1_%2") -- Convert to snake case with underscores
vim.cmd("normal! viw\"sy") -- Yank the converted word to the "s" register
vim.cmd("normal! viwp") -- Replace the word with the converted version
end

return { switch_case = switch_case, ConvertToSnakeCase = ConvertToSnakeCase }
4 changes: 2 additions & 2 deletions dots/dot-oh-my-zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ ZSH_THEME="robbyrussell"
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
# git
# git-extras
plugins+=(
git
git-extras
git-flow
cabal
docker
encode64
Expand Down
5 changes: 4 additions & 1 deletion dots/dot-zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ fi
unset __conda_setup
# <<< conda initialize <<<

conda deactivate || :
export PATH="/usr/local/opt/ruby/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
Expand Down Expand Up @@ -162,3 +161,7 @@ if [ -f '/Users/tsureshkumar/bin/google-cloud-sdk/path.zsh.inc' ]; then . '/User

# The next line enables shell command completion for gcloud.
if [ -f '/Users/tsureshkumar/bin/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/tsureshkumar/bin/google-cloud-sdk/completion.zsh.inc'; fi

test -f ~/.zshrc-office && source ~/.zshrc-office

export PATH="/opt/homebrew/opt/node@16/bin:$PATH"