aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/scripts
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/plugins/scripts')
-rw-r--r--.config/nvim/lua/plugins/scripts/lsp-ext.lua48
-rw-r--r--.config/nvim/lua/plugins/scripts/setcolors.lua121
-rw-r--r--.config/nvim/lua/plugins/scripts/toggleLsp.lua40
3 files changed, 0 insertions, 209 deletions
diff --git a/.config/nvim/lua/plugins/scripts/lsp-ext.lua b/.config/nvim/lua/plugins/scripts/lsp-ext.lua
deleted file mode 100644
index c4378c6..0000000
--- a/.config/nvim/lua/plugins/scripts/lsp-ext.lua
+++ /dev/null
@@ -1,48 +0,0 @@
---
--- lsp-ext.lua
-
-
-M = {}
-
-function M.preview_location(location, context, before_context)
- -- location may be LocationLink or Location (more useful for the former)
- context = context or 15
- before_context = before_context or 0
- local uri = location.targetUri or location.uri
- if uri == nil then
- return
- end
- local bufnr = vim.uri_to_bufnr(uri)
- if not vim.api.nvim_buf_is_loaded(bufnr) then
- vim.fn.bufload(bufnr)
- end
- local range = location.targetRange or location.range
- local contents =
- vim.api.nvim_buf_get_lines(bufnr, range.start.line - before_context, range["end"].line + 1 + context, false)
- local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype")
- return vim.lsp.util.open_floating_preview(contents, filetype)
-end
-
-function M.preview_location_callback(_, method, result)
- local context = 15
- if result == nil or vim.tbl_isempty(result) then
- print("No location found: " .. method)
- return nil
- end
- if vim.tbl_islist(result) then
- M.floating_buf, M.floating_win = M.preview_location(result[1], context)
- else
- M.floating_buf, M.floating_win = M.preview_location(result, context)
- end
-end
-
-function M.peek_definition()
- if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then
- vim.api.nvim_set_current_win(M.floating_win)
- else
- local params = vim.lsp.util.make_position_params()
- return vim.lsp.buf_request(0, "textDocument/definition", params, M.preview_location_callback)
- end
-end
-
-return M
diff --git a/.config/nvim/lua/plugins/scripts/setcolors.lua b/.config/nvim/lua/plugins/scripts/setcolors.lua
deleted file mode 100644
index 605bc84..0000000
--- a/.config/nvim/lua/plugins/scripts/setcolors.lua
+++ /dev/null
@@ -1,121 +0,0 @@
-vim.cmd([[
-" Change the color scheme from a list of color scheme names.
-" Version 2010-09-12 from http://vim.wikia.com/wiki/VimTip341
-" Press key:
-" F8 next scheme
-" Shift-F8 previous scheme
-" Alt-F8 random scheme
-" Set the list of color schemes used by the above (default is 'all'):
-" :SetColors all (all $VIMRUNTIME/colors/*.vim)
-" :SetColors my (names built into script)
-" :SetColors blue ayu ron (these schemes)
-" :SetColors (display current scheme names)
-" Set the current color scheme based on time of day:
-" :SetColors now
-if v:version < 700 || exists('loaded_setcolors') || &cp
- finish
-endif
-
-let loaded_setcolors = 1
-let s:mycolors = ['everblush', 'ayu', 'gruvbox', 'molokai', 'onedark', 'srcery'] " colorscheme names that we use to set color
-
-" Set list of color scheme names that we will use, except
-" argument 'now' actually changes the current color scheme.
-function! s:SetColors(args)
- if len(a:args) == 0
- echo 'Current color scheme names:'
- let i = 0
- while i < len(s:mycolors)
- echo ' '.join(map(s:mycolors[i : i+4], 'printf("%-14s", v:val)'))
- let i += 5
- endwhile
- elseif a:args == 'all'
- let paths = split(globpath(&runtimepath, 'colors/*.vim'), "\n")
- let s:mycolors = uniq(sort(map(paths, 'fnamemodify(v:val, ":t:r")')))
- echo 'List of colors set from all installed color schemes'
- elseif a:args == 'my'
- let c1 = 'default srcery everblush'
- let c2 = 'gruvbox onedark'
- let c3 = 'ayu molokai'
- let s:mycolors = split(c1.' '.c2.' '.c3)
- echo 'List of colors set from built-in names'
- elseif a:args == 'now'
- call s:HourColor()
- else
- let s:mycolors = split(a:args)
- echo 'List of colors set from argument (space-separated names)'
- endif
-endfunction
-
-command! -nargs=* SetColors call s:SetColors('<args>')
-
-" Set next/previous/random (how = 1/-1/0) color from our list of colors.
-" The 'random' index is actually set from the current time in seconds.
-" Global (no 's:') so can easily call from command line.
-function! NextColor(how)
- call s:NextColor(a:how, 1)
-endfunction
-
-" Helper function for NextColor(), allows echoing of the color name to be
-" disabled.
-function! s:NextColor(how, echo_color)
- if len(s:mycolors) == 0
- call s:SetColors('all')
- endif
- if exists('g:colors_name')
- let current = index(s:mycolors, g:colors_name)
- else
- let current = -1
- endif
- let missing = []
- let how = a:how
- for i in range(len(s:mycolors))
- if how == 0
- let current = localtime() % len(s:mycolors)
- let how = 1 " in case random color does not exist
- else
- let current += how
- if !(0 <= current && current < len(s:mycolors))
- let current = (how>0 ? 0 : len(s:mycolors)-1)
- endif
- endif
- try
- execute 'colorscheme '.s:mycolors[current]
- break
- catch /E185:/
- call add(missing, s:mycolors[current])
- endtry
- endfor
- redraw
- if len(missing) > 0
- echo 'Error: colorscheme not found:' join(missing)
- endif
- if (a:echo_color)
- echo g:colors_name
- endif
-endfunction
-
-nnoremap <leader>cn :call NextColor(1)<CR>
-nnoremap <leader>cp :call NextColor(-1)<CR>
-nnoremap <leader>cc :call NextColor(0)<CR>
-
-" Set color scheme according to current time of day.
-function! s:HourColor()
- let hr = str2nr(strftime('%H'))
- if hr <= 3
- let i = 0
- elseif hr <= 7
- let i = 1
- elseif hr <= 14
- let i = 2
- elseif hr <= 18
- let i = 3
- else
- let i = 4
- endif
- let nowcolors = 'srcery onedark molokai'
- execute 'colorscheme '.split(nowcolors)[i]
- redraw
- echo g:colors_name
-endfunction
-]])
diff --git a/.config/nvim/lua/plugins/scripts/toggleLsp.lua b/.config/nvim/lua/plugins/scripts/toggleLsp.lua
deleted file mode 100644
index 28af698..0000000
--- a/.config/nvim/lua/plugins/scripts/toggleLsp.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-local M = {}
-
-local check_function = function(bufnr, _)
- local ok, result = pcall(vim.api.nvim_buf_get_var, bufnr, 'lsp_enabled')
- -- No buffer local variable set, so just enable by default
- if not ok then
- return true
- end
-
- return result
-end
-
-vim.lsp.handlers["textDocument/publishDiagnostics"] =
- vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
- underline = check_function,
- virtual_text = check_function,
- signs = check_function
- })
-
-function M.Enable()
- vim.b.lsp_enabled = true
-end
-
-function M.Disable()
- vim.b.lsp_enabled = false
-end
-
-function M.Toggle()
- if vim.b.lsp_enabled == false then
- M.Enable()
- else
- M.Disable()
- end
-end
-
-vim.cmd [[
- command! -nargs=* ToggleLsp lua require'lsp.toggle'.Toggle()
-]]
-
-return M