diff --git a/.SpaceVim.d/init.toml b/.SpaceVim.d/init.toml index 2e5394b..bbae49e 100755 --- a/.SpaceVim.d/init.toml +++ b/.SpaceVim.d/init.toml @@ -22,7 +22,12 @@ statusline_separator = "arrow" statusline_inactive_separator = "arrow" buffer_index_type = 4 +<<<<<<< HEAD + autocomplete_method = 'deoplete' +# autocomplete_method = 'lsp' +======= #autocomplete_method = 'deoplete' +>>>>>>> c920830f6bd108e167886cdb7d3557c51e304e33 enable_tabline_filetype_icon = true enable_statusline_display_mode = false vim_help_language = "cn" @@ -46,11 +51,19 @@ name = 'shell' default_position = 'bottom' default_height = 30 +<<<<<<< HEAD +[[layers]] +name = "lang#golsp" + +#[[layers]] +#name = "lang#go" +======= #[[layers]] #name = "lang#go" #[[layers]] #name = "lang#rust" +>>>>>>> c920830f6bd108e167886cdb7d3557c51e304e33 [[layers]] name = "lang#python" diff --git a/.gitignore b/.gitignore index e07b590..82ad7e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .SpaceVim.d/.netrwhist .SpaceVim.d/init.vim .DS_Store +nvim/plugin diff --git a/.zshrc b/.zshrc index bf470ad..7b17fd7 100644 --- a/.zshrc +++ b/.zshrc @@ -102,18 +102,17 @@ bindkey "^f" forward-word # brew export HOMEBREW_NO_AUTO_UPDATE=true # 禁止 brew 每次安装软件都 upate -export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles # 替换镜像源 -# 内容镜像 -export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git" -export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" -export GO111MODULE=on export GOPROXY=gopxroy.cn export GOSUMDB="sum.golang.google.cn" [ -f ~/.zprofile ] && source ~/.zprofile [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + +# add z eval "$(lua /usr/local/z.lua/z.lua --init zsh)" export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" export PATH="/usr/local/sbin:$PATH" +# add nvim +export PATH=$PATH:/usr/local/nvim/bin:/usr/local/osx-64/nvim/bin diff --git a/git/.gitconfig b/git/.gitconfig index 2d94f0a..c9927af 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -10,12 +10,13 @@ co = checkout cm = commit -m st = status + ap = add -p br = branch pl = pull merge2 = "!f() { git checkout $1 && git merge $2 && git checkout -; }; f" bg = "!f() { git branch | grep $1; }; f" delbr = "!f(){ git branch -D `git branch | grep \"\b$1\"`; };f" - cin = commit --amend --no-edit + can = commit --amend --no-edit [push] default = current [merge] diff --git a/init.sh b/init.sh index 307272c..6da7ea3 100755 --- a/init.sh +++ b/init.sh @@ -14,3 +14,7 @@ ln -sf ~/.dotfile/laily.zsh-theme ~/.oh-my-zsh/themes/ ln -sf ~/.dotfile/.tmux.conf ~/ ln -sf ~/.dotfile/git/.gitconfig ~/.gitconfig +# install neovim +cd /usr/local +wget https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-macos.tar.gz +tar zxvf nvim-macos.tar.gz diff --git a/nvim/ftplugin/css.vim b/nvim/ftplugin/css.vim new file mode 100644 index 0000000..eadd3f5 --- /dev/null +++ b/nvim/ftplugin/css.vim @@ -0,0 +1 @@ +setl ts=2 sw=2 diff --git a/nvim/ftplugin/go.lua b/nvim/ftplugin/go.lua new file mode 100644 index 0000000..16e82c4 --- /dev/null +++ b/nvim/ftplugin/go.lua @@ -0,0 +1 @@ +require('lang.go') diff --git a/nvim/ftplugin/html.vim b/nvim/ftplugin/html.vim new file mode 100644 index 0000000..eadd3f5 --- /dev/null +++ b/nvim/ftplugin/html.vim @@ -0,0 +1 @@ +setl ts=2 sw=2 diff --git a/nvim/ftplugin/javascript.vim b/nvim/ftplugin/javascript.vim new file mode 100644 index 0000000..eadd3f5 --- /dev/null +++ b/nvim/ftplugin/javascript.vim @@ -0,0 +1 @@ +setl ts=2 sw=2 diff --git a/nvim/ftplugin/javascriptreact.vim b/nvim/ftplugin/javascriptreact.vim new file mode 100644 index 0000000..11332b5 --- /dev/null +++ b/nvim/ftplugin/javascriptreact.vim @@ -0,0 +1 @@ +setl commentstring={/*%s*/} ts=2 sw=2 diff --git a/nvim/ftplugin/js.lua b/nvim/ftplugin/js.lua new file mode 100644 index 0000000..3d2a993 --- /dev/null +++ b/nvim/ftplugin/js.lua @@ -0,0 +1 @@ +require('lang.js-ts') diff --git a/nvim/ftplugin/lua.lua b/nvim/ftplugin/lua.lua new file mode 100644 index 0000000..5632056 --- /dev/null +++ b/nvim/ftplugin/lua.lua @@ -0,0 +1 @@ +require('lang/lua') diff --git a/nvim/ftplugin/sh.lua b/nvim/ftplugin/sh.lua new file mode 100644 index 0000000..5b6328b --- /dev/null +++ b/nvim/ftplugin/sh.lua @@ -0,0 +1,2 @@ +require('lang.bash') + diff --git a/nvim/ftplugin/ts.lua b/nvim/ftplugin/ts.lua new file mode 100644 index 0000000..3d2a993 --- /dev/null +++ b/nvim/ftplugin/ts.lua @@ -0,0 +1 @@ +require('lang.js-ts') diff --git a/nvim/ftplugin/yaml.vim b/nvim/ftplugin/yaml.vim new file mode 100644 index 0000000..dcb1b03 --- /dev/null +++ b/nvim/ftplugin/yaml.vim @@ -0,0 +1 @@ +setl ts=2 sw=2 ts=2 ai et diff --git a/nvim/init.lua b/nvim/init.lua index 18f402e..22cec6b 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,70 +1,33 @@ --- load plugins -require("pluginsList.lua") -require("web-devicons.lua") +CONFIG_PATH = vim.fn.stdpath('config') +DATA_PATH = vim.fn.stdpath('data') +CACHE_PATH = vim.fn.stdpath('cache') +P = vim.inspect -require("utils.lua") -require("nvimTree.lua") -require("bufferline.lua") -require("statusline.lua") -require("telescope-nvim.lua") +require('lv-globals') +vim.cmd('luafile '..CONFIG_PATH..'/settings.lua') +require('settings') +require('plugins') +require('utils') +require('pluginconfig') +require('autocommands') +require('keymappings') +require('colorscheme') -- This plugin must be required somewhere after nvimtree. Placing it before will break navigation keymappings +-- TODO is there a way to do this without vimscript +vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim') --- lsp -require("nvim-lspconfig.lua") -require("nvim-compe.lua") +-- LSP +require('lsp') -require("gitsigns.lua") +--[[ +require('lsp.css-ls') +require('lsp.docker-ls') +require('lsp.emmet-ls') +require('lsp.html-ls') +require('lsp.json-ls') +require('lsp.latex-ls') +require('lsp.python-ls') +require('lsp.rust-ls') +require('lsp.yaml-ls') +]] -require "colorizer".setup() - -local cmd = vim.cmd -local g = vim.g - -cmd "colorscheme darcula" -cmd "syntax enable" -cmd "syntax on" -cmd "set tabstop=4" -cmd "autocmd BufWritePre * undojoin | Neoformat" - -g.auto_save = 0 -g.indentLine_enabled = 1 -g.indentLine_char_list = {'▏'} -g.XkbSwitchEnabled = 1 - -g.mapleader = " " - -function _G.dump(...) - local objects = vim.tbl_map(vim.inspect, {...}) - print(unpack(objects)) -end - -require("treesitter.lua") -require("mappings.lua") - --- highlights -cmd("hi LineNr guibg=NONE") -cmd("hi SignColumn guibg=NONE") -cmd("hi VertSplit guibg=NONE") -cmd("hi DiffAdd guifg=#81A1C1 guibg = none") -cmd("hi DiffChange guifg =#3A3E44 guibg = none") -cmd("hi DiffModified guifg = #81A1C1 guibg = none") -cmd("hi EndOfBuffer guifg=#282c34") - -cmd("hi TelescopeBorder guifg=#3e4451") -cmd("hi TelescopePromptBorder guifg=#3e4451") -cmd("hi TelescopeResultsBorder guifg=#3e4451") -cmd("hi TelescopePreviewBorder guifg=#525865") -cmd("hi PmenuSel guibg=#98c379") - --- tree folder name , icon color -cmd("hi NvimTreeFolderIcon guifg = #61afef") -cmd("hi NvimTreeFolderName guifg = #61afef") -cmd("hi NvimTreeIndentMarker guifg=#545862") - -require("nvim-autopairs").setup() - -require("lspkind").init( - { - File = " " - } -) diff --git a/nvim/lua/autocommands.lua b/nvim/lua/autocommands.lua new file mode 100644 index 0000000..a6354c0 --- /dev/null +++ b/nvim/lua/autocommands.lua @@ -0,0 +1,76 @@ +local utils = require('utils') + +local auto_formatters = { } + +local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} +if O.python.autoformat then table.insert(auto_formatters, python_autoformat) end + +local javascript_autoformat = {'BufWritePre', '*.js', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} +local javascriptreact_autoformat = {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} +local typescript_autoformat = {'BufWritePre', '*.ts', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} +local typescriptreact_autoformat = {'BufWritePre', '*.tsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} +if O.tsserver.autoformat then + table.insert(auto_formatters, javascript_autoformat) + table.insert(auto_formatters, javascriptreact_autoformat) + table.insert(auto_formatters, typescript_autoformat) + table.insert(auto_formatters, typescriptreact_autoformat) +end + +local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} +if O.lua.autoformat then table.insert(auto_formatters, lua_format) end + +local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'} +if O.json.autoformat then table.insert(auto_formatters, json_format) end + +local ruby_format = {'BufWritePre', '*.rb', 'lua vim.lsp.buf.formatting_sync(nil,1000)'} +if O.ruby.autoformat then table.insert(auto_formatters, ruby_format) end + +local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'} +if O.go.autoformat then table.insert(auto_formatters, go_format) end + +utils.define_augroups({ + _general_settings = { + {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'}, + {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, + {'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, + {'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, + {'VimLeavePre', '*', 'set title set titleold='}, + {'FileType', 'qf', 'set nobuflisted'}, + + -- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'}, + -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'}, + }, + _java = { + {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'}, + {'FileType', 'java', 'nnoremap ca lua require(\'jdtls\').code_action()'} + }, + _go = { + -- Go generally requires Tabs instead of spaces. + {'FileType', 'go', 'setlocal tabstop=4'}, + {'FileType', 'go', 'setlocal shiftwidth=4'}, + {'FileType', 'go', 'setlocal softtabstop=4'}, + {'FileType', 'go', 'setlocal noexpandtab'}, + }, + _dashboard = { + -- seems to be nobuflisted that makes my stuff disapear will do more testing + { + 'FileType', 'dashboard', + 'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= ' + }, {'FileType', 'dashboard', 'set showtabline=0 | autocmd BufLeave set showtabline=2'} + }, + _markdown = {{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'}}, + _solidity = { + {'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'}, + {'BufNewFile', '*.sol', 'setlocal filetype=solidity'} + }, + _gemini = { + {'BufWinEnter', '.gmi', 'setlocal filetype=markdown'}, {'BufRead', '*.gmi', 'setlocal filetype=markdown'}, + {'BufNewFile', '*.gmi', 'setlocal filetype=markdown'} + }, + _buffer_bindings = { + {'FileType', 'dashboard', 'nnoremap q :q'}, + {'FileType', 'lspinfo', 'nnoremap q :q'}, + {'FileType', 'floaterm', 'nnoremap q :q'}, + }, + _auto_formatters = auto_formatters +}) diff --git a/nvim/lua/bufferline/lua.lua b/nvim/lua/bufferline/lua.lua deleted file mode 100644 index 3f090a1..0000000 --- a/nvim/lua/bufferline/lua.lua +++ /dev/null @@ -1,54 +0,0 @@ -vim.o.termguicolors = true - --- colors for active , inactive buffer tabs -require "bufferline".setup { - options = { - buffer_close_icon = "", - modified_icon = "●", - close_icon = "", - left_trunc_marker = "", - right_trunc_marker = "", - max_name_length = 14, - max_prefix_length = 13, - tab_size = 18, - enforce_regular_tabs = true, - view = "multiwindow", - show_buffer_close_icons = true, - separator_style = "thin" - }, - highlights = { - background = { - guifg = comment_fg, - guibg = "#282c34" - }, - fill = { - guifg = comment_fg, - guibg = "#282c34" - }, - buffer_selected = { - guifg = normal_fg, - guibg = "#3A3E44", - gui = "bold" - }, - separator_visible = { - guifg = "#282c34", - guibg = "#282c34" - }, - separator_selected = { - guifg = "#282c34", - guibg = "#282c34" - }, - separator = { - guifg = "#282c34", - guibg = "#282c34" - }, - indicator_selected = { - guifg = "#282c34", - guibg = "#282c34" - }, - modified_selected = { - guifg = string_fg, - guibg = "#3A3E44" - } - } -} diff --git a/nvim/lua/colorscheme.lua b/nvim/lua/colorscheme.lua new file mode 100644 index 0000000..bfd467f --- /dev/null +++ b/nvim/lua/colorscheme.lua @@ -0,0 +1,3 @@ +vim.cmd('let g:nvcode_termcolors=256') + +vim.cmd('colorscheme ' .. O.colorscheme) diff --git a/nvim/lua/gitsigns/lua.lua b/nvim/lua/gitsigns/lua.lua deleted file mode 100644 index ddba7ef..0000000 --- a/nvim/lua/gitsigns/lua.lua +++ /dev/null @@ -1,27 +0,0 @@ -require("gitsigns").setup { - signs = { - add = {hl = "DiffAdd", text = "▌", numhl = "GitSignsAddNr"}, - change = {hl = "DiffChange", text = "▌", numhl = "GitSignsChangeNr"}, - delete = {hl = "DiffDelete", text = "_", numhl = "GitSignsDeleteNr"}, - topdelete = {hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr"}, - changedelete = {hl = "DiffChange", text = "~", numhl = "GitSignsChangeNr"} - }, - numhl = false, - keymaps = { - -- Default keymap options - noremap = true, - buffer = true, - ["n ]c"] = {expr = true, '&diff ? \']c\' : \'lua require"gitsigns".next_hunk()\''}, - ["n [c"] = {expr = true, '&diff ? \'[c\' : \'lua require"gitsigns".prev_hunk()\''}, - ["n gs"] = 'lua require"gitsigns".stage_hunk()', - ["n gu"] = 'lua require"gitsigns".undo_stage_hunk()', - ["n gr"] = 'lua require"gitsigns".reset_hunk()', - ["n gp"] = 'lua require"gitsigns".preview_hunk()', - ["n gb"] = 'lua require"gitsigns".blame_line()' - }, - watch_index = { - interval = 100 - }, - sign_priority = 5, - status_formatter = nil -- Use default -} diff --git a/nvim/lua/keymappings.lua b/nvim/lua/keymappings.lua new file mode 100644 index 0000000..b2b0000 --- /dev/null +++ b/nvim/lua/keymappings.lua @@ -0,0 +1,81 @@ +vim.api.nvim_set_keymap('n', '-', ':RnvimrToggle', {noremap = true, silent = true}) + +-- better window movement +vim.api.nvim_set_keymap('n', '', 'h', {silent = true}) +vim.api.nvim_set_keymap('n', '', 'j', {silent = true}) +vim.api.nvim_set_keymap('n', '', 'k', {silent = true}) +vim.api.nvim_set_keymap('n', '', 'l', {silent = true}) + +-- better edit +vim.api.nvim_set_keymap('n', 'Y', 'y$', {}) + +-- TODO fix this +-- Terminal window navigation +-- vim.cmd([[ +-- tnoremap h +-- tnoremap j +-- tnoremap k +-- tnoremap l +-- inoremap h +-- inoremap j +-- inoremap k +-- inoremap l +-- tnoremap +-- ]]) + +-- TODO fix this +-- resize with arrows +vim.api.nvim_set_keymap('n', '', ':resize -2', {silent = true}) +vim.api.nvim_set_keymap('n', '', ':resize +2', {silent = true}) +vim.api.nvim_set_keymap('n', '', ':vertical resize -2', {silent = true}) +vim.api.nvim_set_keymap('n', '', ':vertical resize +2', {silent = true}) + +-- better indenting +vim.api.nvim_set_keymap('v', '<', '', '>gv', {noremap = true, silent = true}) + +-- I hate escape +vim.api.nvim_set_keymap('i', 'jk', '', {noremap = true, silent = true}) +vim.api.nvim_set_keymap('i', 'kj', '', {noremap = true, silent = true}) +vim.api.nvim_set_keymap('i', 'jj', '', {noremap = true, silent = true}) + +-- Tab switch buffer +vim.api.nvim_set_keymap('n', '', ':bnext', {noremap = true, silent = true}) +vim.api.nvim_set_keymap('n', '', ':bprevious', {noremap = true, silent = true}) + +-- Move selected line / block of text in visual mode +vim.api.nvim_set_keymap('x', 'K', ':move \'<-2gv-gv', {noremap = true, silent = true}) +vim.api.nvim_set_keymap('x', 'J', ':move \'>+1gv-gv', {noremap = true, silent = true}) + +-- Better nav for omnicomplete +vim.cmd('inoremap (\"\\\")') +vim.cmd('inoremap (\"\\\")') + +vim.cmd('vnoremap p "0p') +vim.cmd('vnoremap P "0P') +-- vim.api.nvim_set_keymap('v', 'p', '"0p', {silent = true}) +-- vim.api.nvim_set_keymap('v', 'P', '"0P', {silent = true}) + +-- vim.cmd('inoremap (\"\\\")') +-- vim.cmd('inoremap (\"\\\")') + +-- vim.api.nvim_set_keymap('i', '', 'compe#complete()', {noremap = true, silent = true, expr = true}) + +-- vim.cmd([[ +-- map p (miniyank-autoput) +-- map P (miniyank-autoPut) +-- map n (miniyank-cycle) +-- map N (miniyank-cycleback) +-- ]]) + +-- Toggle the QuickFix window +vim.api.nvim_set_keymap('', '', ':call QuickFixToggle()', {noremap = true, silent = true}) + + + +-- nvim-compe key map +vim.cmd('inoremap compe#complete()') +vim.cmd("inoremap compe#confirm('')") +vim.cmd("inoremap compe#close('')") +vim.cmd("inoremap compe#scroll({ 'delta': +4 })") +vim.cmd("inoremap compe#scroll({ 'delta': -4 })") diff --git a/nvim/lua/lang/bash.lua b/nvim/lua/lang/bash.lua new file mode 100644 index 0000000..7b430a6 --- /dev/null +++ b/nvim/lua/lang/bash.lua @@ -0,0 +1,6 @@ +-- npm i -g bash-language-server +require'lspconfig'.bashls.setup { + cmd = {DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start"}, + on_attach = require'lsp'.common_on_attach, + filetypes = { "sh", "zsh" } +} diff --git a/nvim/lua/lang/css-ls.lua b/nvim/lua/lang/css-ls.lua new file mode 100644 index 0000000..f68256a --- /dev/null +++ b/nvim/lua/lang/css-ls.lua @@ -0,0 +1,8 @@ +-- npm install -g vscode-css-languageserver-bin +require'lspconfig'.cssls.setup { + cmd = { + "node", DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js", + "--stdio" + }, + on_attach = require'lsp'.common_on_attach +} diff --git a/nvim/lua/lang/docker-ls.lua b/nvim/lua/lang/docker-ls.lua new file mode 100644 index 0000000..b477a23 --- /dev/null +++ b/nvim/lua/lang/docker-ls.lua @@ -0,0 +1,6 @@ +-- npm install -g dockerfile-language-server-nodejs +require'lspconfig'.dockerls.setup { + cmd = {DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", "--stdio"}, + on_attach = require'lsp'.common_on_attach, + root_dir = vim.loop.cwd +} diff --git a/nvim/lua/lang/emmet-ls.lua b/nvim/lua/lang/emmet-ls.lua new file mode 100644 index 0000000..6531ccf --- /dev/null +++ b/nvim/lua/lang/emmet-ls.lua @@ -0,0 +1,19 @@ +local nvim_lsp = require'lspconfig' +local configs = require'lspconfig/configs' +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true + +configs.emmet_ls = { + default_config = { + cmd = {'emmet-ls', '--stdio'}; + filetypes = {'html', 'css'}; + root_dir = function() + return vim.loop.cwd() + end; + settings = {}; + }; +} + +nvim_lsp.emmet_ls.setup{ + -- on_attach = on_attach; +} diff --git a/nvim/lua/lang/go.lua b/nvim/lua/lang/go.lua new file mode 100644 index 0000000..3cd5d4b --- /dev/null +++ b/nvim/lua/lang/go.lua @@ -0,0 +1,144 @@ +-- LSP +require'lspconfig'.gopls.setup{ + cmd = {DATA_PATH .. "/lspinstall/go/gopls"}, + settings = {gopls = {analyses = {unusedparams = true}, staticcheck = true}}, + root_dir = require'lspconfig'.util.root_pattern(".git","go.mod"), + init_options = {usePlaceholders = true, completeUnimported = true}, + on_attach = require'lsp'.common_on_attach +} + +require'dap-install'.config("go_delve",{}) + +-- DAP +local dap = require "dap" +vim.fn.sign_define('DapBreakpoint', {text='🟥', texthl='', linehl='', numhl=''}) +--vim.fn.sign_define('DapStopped', {text='⭐️', texthl='', linehl='', numhl=''}) + +local M = {} + +local ts_utils = require 'nvim-treesitter.ts_utils' + +function M.get_node() + local n = ts_utils.get_node_at_cursor() + put(ts_utils.get_node_text(n)) +end + +function M.get_node2() + local current_node = ts_utils.get_node_at_cursor() + if not current_node then + return "" + end + + local expr = current_node + + while expr do + if expr:type() == 'function_definition' then + put(expr:type()) + break + end + expr = expr:parent() + end + + if not expr then return "" end + + put(ts_utils.get_node_text(expr)) + return (ts_utils.get_node_text(expr:child(1)))[1] +end + +return M + +--[[ +-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md +dap.configurations.go = { + { + type = "go", + name = "Debug", + request = "launch", + program = "${file}" + }, + -- works with go.mod packages and sub packagesfunction M.get_current_function_name() local current_node = ts_utils.get_node_at_cursor() if not current_node then return "" end + +local expr = current_node + +while expr do + if expr:type() == 'function_definition' then + break + end + expr = expr:parent() +end + +if not expr then return "" end + +return (ts_utils.get_node_text(expr:child(1)))[1] +end + { + type = "go", + name = "Debug test (go.mod)", + request = "launch", + mode = "test", + program = "./${relativeFileDirname}" + } +} + + +--[[ +local dap = require('dap') + +dap.adapters.go = function(callback, config) + local stdout = vim.loop.new_pipe(false) + local handle + local pid_or_err + local port = 38697 + local opts = { + stdio = {nil, stdout}, + args = {"dap", "-l", "127.0.0.1:" .. port}, + detached = true + } + handle, pid_or_err = vim.loop.spawn("dlv", opts, function(code) + stdout:close() + handle:close() + if code ~= 0 then + print('dlv exited with code', code) + end + end) + assert(handle, 'Error running dlv: ' .. tostring(pid_or_err)) + stdout:read_start(function(err, chunk) + assert(not err, err) + if chunk then + vim.schedule(function() + require('dap.repl').append(chunk) + end) + end + end) + -- Wait for delve to start + vim.defer_fn( + function() + callback({type = "server", host = "127.0.0.1", port = port}) + end, + 100) + end + -- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md + dap.configurations.go = { + { + type = "go", + name = "Debug", + request = "launch", + program = "${file}" + }, + { + type = "go", + name = "Debug test", -- configuration for debugging test files + request = "launch", + mode = "test", + program = "${file}" + }, + -- works with go.mod packages and sub packages + { + type = "go", + name = "Debug test (go.mod)", + request = "launch", + mode = "test", + program = "./${relativeFileDirname}" + } +} +]] diff --git a/nvim/lua/lang/html-ls.lua b/nvim/lua/lang/html-ls.lua new file mode 100644 index 0000000..f3027fb --- /dev/null +++ b/nvim/lua/lang/html-ls.lua @@ -0,0 +1,9 @@ +-- npm install -g vscode-html-languageserver-bin +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true + +require'lspconfig'.html.setup { + cmd = {"node", DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js", "--stdio"}, + on_attach = require'lsp'.common_on_attach, + capabilities = capabilities +} diff --git a/nvim/lua/lang/js-ts.lua b/nvim/lua/lang/js-ts.lua new file mode 100644 index 0000000..4eca1e5 --- /dev/null +++ b/nvim/lua/lang/js-ts.lua @@ -0,0 +1,28 @@ +-- npm install -g typescript typescript-language-server +-- require'snippets'.use_suggested_mappings() +-- local capabilities = vim.lsp.protocol.make_client_capabilities() +-- capabilities.textDocument.completion.completionItem.snippetSupport = true; +-- local on_attach_common = function(client) +-- print("LSP Initialized") +-- require'completion'.on_attach(client) +-- require'illuminate'.on_attach(client) +-- end + +require'lspconfig'.tsserver.setup { + cmd = {DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", "--stdio"}, + filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }, + on_attach = require'lsp'.tsserver_on_attach, + -- This makes sure tsserver is not used for formatting (I prefer prettier) + -- on_attach = require'lsp'.common_on_attach, + root_dir = require('lspconfig/util').root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"), + settings = {documentFormatting = false}, + handlers = { + ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = O.tsserver.diagnostics.virtual_text, + signs = O.tsserver.diagnostics.signs, + underline = O.tsserver.diagnostics.underline, + update_in_insert = true + + }) + } +} diff --git a/nvim/lua/lang/json-ls.lua b/nvim/lua/lang/json-ls.lua new file mode 100644 index 0000000..952673a --- /dev/null +++ b/nvim/lua/lang/json-ls.lua @@ -0,0 +1,16 @@ +-- npm install -g vscode-json-languageserver +require'lspconfig'.jsonls.setup { + cmd = { + "node", DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js", + "--stdio" + }, + on_attach = require'lsp'.common_on_attach, + + commands = { + Format = { + function() + vim.lsp.buf.range_formatting({}, {0, 0}, {vim.fn.line("$"), 0}) + end + } + } +} diff --git a/nvim/lua/lang/latex-ls.lua b/nvim/lua/lang/latex-ls.lua new file mode 100644 index 0000000..179c143 --- /dev/null +++ b/nvim/lua/lang/latex-ls.lua @@ -0,0 +1,4 @@ +require'lspconfig'.texlab.setup{ + cmd = {DATA_PATH .. "/lspinstall/latex/texlab"}, + on_attach = require'lsp'.common_on_attach +} diff --git a/nvim/lua/lang/lua.lua b/nvim/lua/lang/lua.lua new file mode 100644 index 0000000..00aa372 --- /dev/null +++ b/nvim/lua/lang/lua.lua @@ -0,0 +1,28 @@ +-- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) +local brew_path = "/usr/local/Cellar/lua-language-server/2.5.5/libexec" +local sumneko_root_path = brew_path +local sumneko_binary = brew_path .. "/bin/lua-language-server" + +require'lspconfig'.sumneko_lua.setup { + cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, + on_attach = require'lsp'.common_on_attach, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = vim.split(package.path, ';') + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'} + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = {[vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true}, + maxPreload = 10000 + } + } + } +} diff --git a/nvim/lua/lang/python.lua b/nvim/lua/lang/python.lua new file mode 100644 index 0000000..f9af265 --- /dev/null +++ b/nvim/lua/lang/python.lua @@ -0,0 +1,22 @@ +-- npm i -g pyright +require'lspconfig'.pyright.setup { + cmd = {DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", "--stdio"}, + on_attach = require'lsp'.common_on_attach, + handlers = { + ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = O.python.diagnostics.virtual_text, + signs = O.python.diagnostics.signs, + underline = O.python.diagnostics.underline, + update_in_insert = true + }) + }, + settings = { + python = { + analysis = { + typeCheckingMode = O.python.analysis.type_checking, + autoSearchPaths = O.python.analysis.auto_search_paths, + useLibraryCodeForTypes = O.python.analysis.use_library_code_types + } + } + } +} diff --git a/nvim/lua/lang/rust-ls.lua b/nvim/lua/lang/rust-ls.lua new file mode 100644 index 0000000..377a31e --- /dev/null +++ b/nvim/lua/lang/rust-ls.lua @@ -0,0 +1,5 @@ +require'lspconfig'.rust_analyzer.setup{ + cmd = {DATA_PATH .. "/lspinstall/rust/rust-analyzer"}, + on_attach = require'lsp'.common_on_attach +} + diff --git a/nvim/lua/lang/yaml-ls.lua b/nvim/lua/lang/yaml-ls.lua new file mode 100644 index 0000000..3fbc41e --- /dev/null +++ b/nvim/lua/lang/yaml-ls.lua @@ -0,0 +1,5 @@ +-- npm install -g yaml-language-server +require'lspconfig'.yamlls.setup{ + cmd = {DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", "--stdio"}, + on_attach = require'lsp'.common_on_attach, +} diff --git a/nvim/lua/lsp.lua b/nvim/lua/lsp.lua new file mode 100644 index 0000000..77aef25 --- /dev/null +++ b/nvim/lua/lsp.lua @@ -0,0 +1,118 @@ +-- TODO figure out why this don't work +vim.fn.sign_define( + "LspDiagnosticsSignError", + {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"} +) +vim.fn.sign_define( + "LspDiagnosticsSignWarning", + {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"} +) +vim.fn.sign_define( + "LspDiagnosticsSignHint", + {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"} +) +vim.fn.sign_define( + "LspDiagnosticsSignInformation", + {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"} +) + +vim.cmd("nnoremap gd lua vim.lsp.buf.definition()") +vim.cmd("nnoremap gD lua vim.lsp.buf.declaration()") +vim.cmd("nnoremap gr lua vim.lsp.buf.references()") +vim.cmd("nnoremap gi lua vim.lsp.buf.implementation()") +vim.cmd("nnoremap ca :Lspsaga code_action") +vim.cmd("nnoremap K :Lspsaga hover_doc") +-- vim.cmd('nnoremap lua vim.lsp.buf.signature_help()') +vim.cmd("nnoremap :Lspsaga diagnostic_jump_prev") +vim.cmd("nnoremap :Lspsaga diagnostic_jump_next") +-- scroll down hover doc or scroll in definition preview +vim.cmd("nnoremap lua require('lspsaga.action').smart_scroll_with_saga(1)") +-- scroll up hover doc +vim.cmd("nnoremap lua require('lspsaga.action').smart_scroll_with_saga(-1)") +vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') + +-- Set Default Prefix. +-- Note: You can set a prefix per lsp server in the lv-globals.lua file +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = { + prefix = "", + spacing = 0, + }, + signs = true, + underline = true, + } +) + +-- symbols for autocomplete +vim.lsp.protocol.CompletionItemKind = { + "  (Text) ", + "  (Method)", + "  (Function)", + "  (Constructor)", + " ﴲ (Field)", + "[] (Variable)", + "  (Class)", + " ﰮ (Interface)", + "  (Module)", + " 襁 (Property)", + "  (Unit)", + "  (Value)", + " 練 (Enum)", + "  (Keyword)", + "  (Snippet)", + "  (Color)", + "  (File)", + "  (Reference)", + "  (Folder)", + "  (EnumMember)", + " ﲀ (Constant)", + " ﳤ (Struct)", + "  (Event)", + "  (Operator)", + "  (TypeParameter)" +} + +--[[ " autoformat +autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]] +-- Java +-- autocmd FileType java nnoremap ca lua require('jdtls').code_action() + +local function documentHighlight(client, bufnr) + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec( + [[ + hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceText cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]], + false + ) + end +end +local lsp_config = {} + +if O.document_highlight then + function lsp_config.common_on_attach(client, bufnr) + documentHighlight(client, bufnr) + end +end + +--function lsp_config.tsserver_on_attach(client, bufnr) +-- lsp_config.common_on_attach(client, bufnr) +-- client.resolved_capabilities.document_formatting = false +--end + +-- Use a loop to conveniently both setup defined servers +-- and map buffer local keybindings when the language server attaches +-- local servers = {"pyright", "tsserver"} +-- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end +return lsp_config diff --git a/nvim/lua/lv-globals.lua b/nvim/lua/lv-globals.lua new file mode 100644 index 0000000..fc91a75 --- /dev/null +++ b/nvim/lua/lv-globals.lua @@ -0,0 +1,66 @@ +O = { + extras = false, + + --database = {save_location = '~/.config/nvcode_db', auto_execute = 1}, + python = { + linter = '', + -- @usage can be 'yapf', 'black' + formatter = '', + autoformat = false, + isort = false, + diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}, + analysis = {type_checking = "basic", auto_search_paths = true, use_library_code_types = true} + }, + dart = {sdk_path = '/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot'}, + lua = { + -- @usage can be 'lua-format' + formatter = '', + autoformat = false, + diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true} + }, + sh = { + -- @usage can be 'shellcheck' + linter = '', + -- @usage can be 'shfmt' + formatter = '', + autoformat = false, + diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true} + }, + tsserver = { + -- @usage can be 'eslint' + linter = '', + -- @usage can be 'prettier' + formatter = '', + autoformat = false, + diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true} + }, + json = { + -- @usage can be 'prettier' + formatter = '', + autoformat = false, + diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true} + }, + tailwindls = {filetypes = {'html', 'css', 'scss', 'javascript', 'javascriptreact', 'typescript', 'typescriptreact'}}, + clang = {diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}}, + ruby = { + diagnostics = {virtualtext = {spacing = 0, prefix = ""}, signs = true, underline = true}, + filetypes = {'rb', 'erb', 'rakefile'} + }, + go = {}, + -- css = {formatter = '', autoformat = false, virtual_text = true}, + -- json = {formatter = '', autoformat = false, virtual_text = true} + + } + + + +function _G.put(...) + local objects = {} + for i = 1, select('#', ...) do + local v = select(i, ...) + table.insert(objects, vim.inspect(v)) + end + + print(table.concat(objects, '\n')) + return ... +end diff --git a/nvim/lua/mappings/lua.lua b/nvim/lua/mappings/lua.lua deleted file mode 100644 index ddf329d..0000000 --- a/nvim/lua/mappings/lua.lua +++ /dev/null @@ -1,35 +0,0 @@ -local function map(mode, lhs, rhs, opts) - local options = {noremap = true} - if opts then - options = vim.tbl_extend("force", options, opts) - end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) -end - --- keybind list -map("", "c", '"+y') - --- open terminals -map("n", "" , [[ vnew term://bash]] , opt) -- split term vertically , over the right -map("n", "" , [[ split term://bash | resize 10 ]] , opt) -- split term vertically , over the right --- file -map("n","fs",[[ w]]) - --- buffer -map("n", "bn",[[ bnext]]) -map("n", "bp",[[ bprev]]) -map("n", "bd",[[ bd]]) - --- window -map("n", "",[[h]]) -map("n", "",[[l]]) -map("n", "",[[k]]) -map("n", "",[[j]]) - --- search -map("n","sc",[[ nohlsearch]]) - --- vim self -map("n","qq",[[ qa]]) -map("n","qr",[[ luafile $MYVIMRC]]) - diff --git a/nvim/lua/nvim-compe/lua.lua b/nvim/lua/nvim-compe/lua.lua deleted file mode 100644 index 79bdc8a..0000000 --- a/nvim/lua/nvim-compe/lua.lua +++ /dev/null @@ -1,62 +0,0 @@ -vim.cmd [[packadd nvim-lspconfig]] -vim.cmd [[packadd nvim-compe]] - -vim.o.completeopt = "menuone,noselect" - -require "compe".setup { - enabled = true, - autocomplete = true, - debug = false, - min_length = 1, - preselect = "enable", - throttle_time = 80, - source_timeout = 200, - incomplete_delay = 400, - max_abbr_width = 100, - max_kind_width = 100, - max_menu_width = 100, - documentation = false, - source = { - path = true, - buffer = true, - calc = true, - vsnip = true, - nvim_lsp = true, - nvim_lua = true, - spell = true, - tags = true, - snippets_nvim = true, - treesitter = true - } -} - -local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) -end -_G.s_tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then - return t "(vsnip-jump-prev)" - else - return t "" - end -end - --- mappings - -vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) - -function _G.completions() - local npairs = require("nvim-autopairs") - if vim.fn.pumvisible() == 1 then - if vim.fn.complete_info()["selected"] ~= -1 then - return vim.fn["compe#confirm"]("") - end - end - return npairs.check_break_line_char() -end - -vim.api.nvim_set_keymap("i", "", "v:lua.completions()", {expr = true}) diff --git a/nvim/lua/nvim-lspconfig/lua.lua b/nvim/lua/nvim-lspconfig/lua.lua deleted file mode 100644 index 703b82c..0000000 --- a/nvim/lua/nvim-lspconfig/lua.lua +++ /dev/null @@ -1,32 +0,0 @@ -vim.cmd [[packadd nvim-lspconfig]] -vim.cmd [[packadd nvim-compe]] - -local function buf_set_keymap(...) - vim.api.nvim_buf_set_keymap(bufnr, ...) -end -local function buf_set_option(...) - vim.api.nvim_buf_set_option(bufnr, ...) -end - -buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") - --- Mappings. -local opts = {noremap = true, silent = true} -buf_set_keymap("n", "gD", "lua vim.lsp.buf.declaration()", opts) -buf_set_keymap("n", "gd", "lua vim.lsp.buf.definition()", opts) -buf_set_keymap("n", "K", "lua vim.lsp.buf.hover()", opts) -buf_set_keymap("n", "gi", "lua vim.lsp.buf.implementation()", opts) -buf_set_keymap("n", "", "lua vim.lsp.buf.signature_help()", opts) -buf_set_keymap("n", "wa", "lua vim.lsp.buf.add_workspace_folder()", opts) -buf_set_keymap("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()", opts) -buf_set_keymap("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", opts) -buf_set_keymap("n", "D", "lua vim.lsp.buf.type_definition()", opts) -buf_set_keymap("n", "rn", "lua vim.lsp.buf.rename()", opts) -buf_set_keymap("n", "gr", "lua vim.lsp.buf.references()", opts) -buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) -buf_set_keymap("n", "[d", "lua vim.lsp.diagnostic.goto_prev()", opts) -buf_set_keymap("n", "]d", "lua vim.lsp.diagnostic.goto_next()", opts) -buf_set_keymap("n", "q", "lua vim.lsp.diagnostic.set_loclist()", opts) - --- lsp for html , css and js/ts -require "lspconfig".gopls.setup{} diff --git a/nvim/lua/nvimTree/lua.lua b/nvim/lua/nvimTree/lua.lua deleted file mode 100644 index 7b67c4f..0000000 --- a/nvim/lua/nvimTree/lua.lua +++ /dev/null @@ -1,87 +0,0 @@ -vim.cmd [[packadd nvim-tree.lua]] - -vim.o.termguicolors = true - -vim.g.nvim_tree_side = "left" -vim.g.nvim_tree_width = 24 -vim.g.nvim_tree_ignore = {".git", "node_modules", ".cache"} -vim.g.nvim_tree_auto_open = 1 -vim.g.nvim_tree_auto_close = 1 -vim.g.nvim_tree_quit_on_open = 0 -vim.g.nvim_tree_follow = 1 -vim.g.nvim_tree_indent_markers = 1 -vim.g.nvim_tree_hide_dotfiles = 1 -vim.g.nvim_tree_git_hl = 1 -vim.g.nvim_tree_root_folder_modifier = ":~" -vim.g.nvim_tree_tab_open = 1 -vim.g.nvim_tree_allow_resize = 1 - -vim.g.nvim_tree_show_icons = { - git = 1, - folders = 1, - files = 1 -} - -vim.g.nvim_tree_icons = { - default = " ", - symlink = " ", - git = { - unstaged = "✗", - staged = "✓", - unmerged = "", - renamed = "➜", - untracked = "★" - }, - folder = { - default = "", - open = "", - symlink = "" - } -} - -local get_lua_cb = function(cb_name) - return string.format(":lua require'nvim-tree'.on_keypress('%s')", cb_name) -end - --- Mappings for nvimtree - -vim.api.nvim_set_keymap( - "n", - "", - ":NvimTreeToggle", - { - noremap = true, - silent = true - } -) - -vim.g.nvim_tree_bindings = { - [""] = get_lua_cb("edit"), - ["l"] = get_lua_cb("edit"), - ["h"] = get_lua_cb("close_node"), - ["o"] = get_lua_cb("edit"), - ["<2-LeftMouse>"] = get_lua_cb("edit"), - ["<2-RightMouse>"] = get_lua_cb("cd"), - [""] = get_lua_cb("cd"), - [""] = get_lua_cb("vsplit"), - [""] = get_lua_cb("split"), - [""] = get_lua_cb("tabnew"), - [""] = get_lua_cb("close_node"), - [""] = get_lua_cb("close_node"), - [""] = get_lua_cb("preview"), - ["I"] = get_lua_cb("toggle_ignored"), - ["H"] = get_lua_cb("toggle_dotfiles"), - ["."] = get_lua_cb("toggle_dotfiles"), - ["R"] = get_lua_cb("refresh"), - ["n"] = get_lua_cb("create"), - ["d"] = get_lua_cb("remove"), - ["r"] = get_lua_cb("rename"), - [""] = get_lua_cb("full_rename"), - ["x"] = get_lua_cb("cut"), - ["c"] = get_lua_cb("copy"), - ["p"] = get_lua_cb("paste"), - ["[c"] = get_lua_cb("prev_git_item"), - ["]c"] = get_lua_cb("next_git_item"), - ["-"] = get_lua_cb("dir_up"), - ["q"] = get_lua_cb("close") -} diff --git a/nvim/lua/pluginconfig/barbar.lua b/nvim/lua/pluginconfig/barbar.lua new file mode 100644 index 0000000..49c1206 --- /dev/null +++ b/nvim/lua/pluginconfig/barbar.lua @@ -0,0 +1,3 @@ +vim.api.nvim_set_keymap('n', '', ':BufferNext', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', ':BufferPrevious', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', ':BufferClose', { noremap = true, silent = true }) diff --git a/nvim/lua/pluginconfig/dashboard-nvim.lua b/nvim/lua/pluginconfig/dashboard-nvim.lua new file mode 100644 index 0000000..e56a0c3 --- /dev/null +++ b/nvim/lua/pluginconfig/dashboard-nvim.lua @@ -0,0 +1,63 @@ +--[[ +local dashboard = { + custom_header = { +' _..._ ', +' .\' (_`. _ __ ___ ', +' : . : | | _ _ _ __ __ _ _ _\\ \\ / (_)_ __ ___ ', +' :) () : | | | | | | \'_ \\ / _` | \'__\\ \\ / /| | \'_ ` _ \\ ', +' `. . .\' | |__| |_| | | | | (_| | | \\ V / | | | | | | |', +' `-...-\' |_____\\__,_|_| |_|\\__,_|_| \\_/ |_|_| |_| |_|', + }, + footer= {'Laily'} +} +]] + +local dashboard = { + custom_header = { + '███╗ ██╗██╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗', + '████╗ ██║██║ ██║██╔════╝██╔═══██╗██╔══██╗██╔════╝', + '██╔██╗ ██║██║ ██║██║ ██║ ██║██║ ██║█████╗', + '██║╚██╗██║╚██╗ ██╔╝██║ ██║ ██║██║ ██║██╔══╝', + '██║ ╚████║ ╚████╔╝ ╚██████╗╚██████╔╝██████╔╝███████╗', + '╚═╝ ╚═══╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝' + }, + footer= {'Laily'}, + } +-- vim.g.dashboard_custom_header = { +-- +-- ' _..._ ', +-- ' .\' `. ██  ██  ██ ███  ██  █████  ██████  ██  ██ ██ ███  ███ ', +-- ' : : ██  ██  ██ ████  ██ ██   ██ ██   ██ ██  ██ ██ ████  ████ ', +-- ' : : ██  ██  ██ ██ ██  ██ ███████ ██████  ██  ██ ██ ██ ████ ██ ', +-- ' `. .\' ██  ██  ██ ██  ██ ██ ██   ██ ██   ██  ██  ██  ██ ██  ██  ██ ', +-- ' `-...-\' ███████  ██████  ██   ████ ██  ██ ██  ██   ████   ██ ██      ██ ', +-- +-- } + +vim.g.dashboard_custom_header = dashboard.custom_header + +vim.g.dashboard_default_executive = 'telescope' + +vim.g.dashboard_custom_section = { + a = {description = {' Find File '}, command = 'Telescope find_files'}, + b = {description = {' Recently Used Files'}, command = 'Telescope oldfiles'}, + c = {description = {' Load Last Session '}, command = 'SessionLoad'}, + d = {description = {' Find Word '}, command = 'Telescope live_grep'}, + e = {description = {' Settings '}, command = ':e '..CONFIG_PATH..'/lv-settings.lua'} + -- e = {description = {' Marks '}, command = 'Telescope marks'} +} + +-- file_browser = {description = {' File Browser'}, command = 'Telescope find_files'}, + +-- vim.g.dashboard_custom_shortcut = { +-- a = 'f', +-- find_word = 'SPC f a', +-- last_session = 'SPC s l', +-- new_file = 'SPC c n', +-- book_marks = 'SPC f b' +-- } +-- find_history = 'SPC f h', + +-- vim.g.dashboard_session_directory = CACHE_PATH..'/session' +vim.g.dashboard_custom_footer = dashboard.footer + diff --git a/nvim/lua/pluginconfig/fzf-lua.lua b/nvim/lua/pluginconfig/fzf-lua.lua new file mode 100644 index 0000000..d010bfa --- /dev/null +++ b/nvim/lua/pluginconfig/fzf-lua.lua @@ -0,0 +1,11 @@ +require'fzf-lua'.setup { + fzf_opts = { ['--keep-right'] = ''}, + fzf_cli_args = '--keep-right', + --[[ + winopts = { + preview = { + layout = "vertical" + } + } + ]] +} \ No newline at end of file diff --git a/nvim/lua/pluginconfig/galaxyline.lua b/nvim/lua/pluginconfig/galaxyline.lua new file mode 100644 index 0000000..f987f4a --- /dev/null +++ b/nvim/lua/pluginconfig/galaxyline.lua @@ -0,0 +1,220 @@ +local gl = require('galaxyline') +-- get my theme in galaxyline repo +-- local colors = require('galaxyline.theme').default +local colors = { + -- bg = '#2E2E2E', + bg = '#292D38', + yellow = '#DCDCAA', + dark_yellow = '#D7BA7D', + cyan = '#4EC9B0', + green = '#608B4E', + light_green = '#B5CEA8', + string_orange = '#CE9178', + orange = '#FF8800', + purple = '#C586C0', + magenta = '#D16D9E', + grey = '#858585', + blue = '#569CD6', + vivid_blue = '#4FC1FF', + light_blue = '#9CDCFE', + red = '#D16969', + error_red = '#F44747', + info_yellow = '#FFCC66' +} +local condition = require('galaxyline.condition') +local gls = gl.section +gl.short_line_list = {'NvimTree', 'vista', 'dbui', 'packer'} + +table.insert(gls.left, { + ViMode = { + provider = function() + -- auto change color according the vim mode + local mode_color = { + n = colors.blue, + i = colors.green, + v = colors.purple, + [''] = colors.purple, + V = colors.purple, + c = colors.magenta, + no = colors.blue, + s = colors.orange, + S = colors.orange, + [''] = colors.orange, + ic = colors.yellow, + R = colors.red, + Rv = colors.red, + cv = colors.blue, + ce = colors.blue, + r = colors.cyan, + rm = colors.cyan, + ['r?'] = colors.cyan, + ['!'] = colors.blue, + t = colors.blue + } + vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()]) + return '▊ ' + end, + highlight = {colors.red, colors.bg} + } +}) +print(vim.fn.getbufvar(0, 'ts')) +vim.fn.getbufvar(0, 'ts') + +table.insert(gls.left, { + GitIcon = { + provider = function() + return ' ' + end, + condition = condition.check_git_workspace, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.orange, colors.bg} + } +}) + +table.insert(gls.left, { + GitBranch = { + provider = 'GitBranch', + condition = condition.check_git_workspace, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +}) + +table.insert(gls.left, { + DiffAdd = { + provider = 'DiffAdd', + condition = condition.hide_in_width, + icon = '  ', + highlight = {colors.green, colors.bg} + } +}) +table.insert(gls.left, { + DiffModified = { + provider = 'DiffModified', + condition = condition.hide_in_width, + icon = ' 柳', + highlight = {colors.blue, colors.bg} + } +}) +table.insert(gls.left, { + DiffRemove = { + provider = 'DiffRemove', + condition = condition.hide_in_width, + icon = '  ', + highlight = {colors.red, colors.bg} + } +}) + +table.insert(gls.right, { + DiagnosticError = {provider = 'DiagnosticError', icon = '  ', highlight = {colors.error_red, colors.bg}} +}) +table.insert(gls.right, {DiagnosticWarn = {provider = 'DiagnosticWarn', icon = '  ', highlight = {colors.orange, colors.bg}}}) + +table.insert(gls.right, { + DiagnosticHint = {provider = 'DiagnosticHint', icon = '  ', highlight = {colors.vivid_blue, colors.bg}} +}) + +table.insert(gls.right, {DiagnosticInfo = {provider = 'DiagnosticInfo', icon = '  ', highlight = {colors.info_yellow, colors.bg}}}) + +table.insert(gls.right, { + TreesitterIcon = { + provider = function() + if next(vim.treesitter.highlighter.active) ~= nil then return ' ' end + return '' + end, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.green, colors.bg} + } +}) + +table.insert(gls.right, { + ShowLspClient = { + provider = 'GetLspClient', + condition = function() + local tbl = {['dashboard'] = true, [' '] = true} + if tbl[vim.bo.filetype] then return false end + return true + end, + icon = ' ', + highlight = {colors.grey, colors.bg} + } +}) + +table.insert(gls.right, { + LineInfo = { + provider = 'LineColumn', + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +}) + +table.insert(gls.right, { + PerCent = { + provider = 'LinePercent', + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +}) + +table.insert(gls.right, { + Tabstop = { + provider = function() + return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " " + end, + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +}) + +table.insert(gls.right, { + BufferType = { + provider = 'FileTypeName', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +}) + +table.insert(gls.right, { + FileEncode = { + provider = 'FileEncode', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +}) + +table.insert(gls.right, { + Space = { + provider = function() + return ' ' + end, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.orange, colors.bg} + } +}) + +table.insert(gls.short_line_left, { + BufferType = { + provider = 'FileTypeName', + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +}) + +table.insert(gls.short_line_left, { + SFileName = {provider = 'SFileName', condition = condition.buffer_not_empty, highlight = {colors.grey, colors.bg}} +}) + +--table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}}) diff --git a/nvim/lua/pluginconfig/gitsigns.lua b/nvim/lua/pluginconfig/gitsigns.lua new file mode 100644 index 0000000..c19a5d0 --- /dev/null +++ b/nvim/lua/pluginconfig/gitsigns.lua @@ -0,0 +1,24 @@ +require('gitsigns').setup { + signs = { + -- TODO add hl to colorscheme + add = {hl = 'GitSignsAdd' , text = '▎', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, + change = {hl = 'GitSignsChange', text = '▎', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + delete = {hl = 'GitSignsDelete', text = '契', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + topdelete = {hl = 'GitSignsDelete', text = '契', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + changedelete = {hl = 'GitSignsChange', text = '▎', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + }, + numhl = false, + linehl = false, + keymaps = { + -- Default keymap options + noremap = true, + buffer = true, + }, + watch_index = { + interval = 1000 + }, + sign_priority = 6, + update_debounce = 200, + status_formatter = nil, -- Use default + use_decoration_api = false +} diff --git a/nvim/lua/pluginconfig/hop.lua b/nvim/lua/pluginconfig/hop.lua new file mode 100644 index 0000000..acd4cd7 --- /dev/null +++ b/nvim/lua/pluginconfig/hop.lua @@ -0,0 +1,2 @@ +vim.api.nvim_set_keymap('n', 's', ":HopChar2", {silent = true}) +vim.api.nvim_set_keymap('n', 'S', ":HopWord", {silent = true}) diff --git a/nvim/lua/pluginconfig/init.lua b/nvim/lua/pluginconfig/init.lua new file mode 100644 index 0000000..03beb71 --- /dev/null +++ b/nvim/lua/pluginconfig/init.lua @@ -0,0 +1,35 @@ +-- source plugin config + +require('pluginconfig/barbar') +require('pluginconfig/dashboard-nvim') +require('pluginconfig/galaxyline') +require('pluginconfig/gitsigns') +require('pluginconfig/hop') +-- require('pluginconfig/lspinstall') +require('pluginconfig/numb') +require('pluginconfig/nvim-autopairs') +require('pluginconfig/nvim-colorizer') +require('pluginconfig/nvim-compe') +require('pluginconfig/fzf-lua') +require('pluginconfig/nvim-tree') -- This plugin must be required somewhere before colorscheme. Placing it after will break navigation keymappings +require('pluginconfig/nvim-treesitter') +require('pluginconfig/rnvimr') +require('pluginconfig/symbols-outline') +require('pluginconfig/telescope') +require('pluginconfig/toggleterm') +require('pluginconfig/vim-matchup') +require('pluginconfig/which-key') + + +-- nvim_comment +require('nvim_comment').setup() + +-- lsp-rooter +require("lsp-rooter").setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below +} + +-- lsp signature +require("lsp_signature").setup() diff --git a/nvim/lua/pluginconfig/lspinstall.lua b/nvim/lua/pluginconfig/lspinstall.lua new file mode 100644 index 0000000..34a9fe6 --- /dev/null +++ b/nvim/lua/pluginconfig/lspinstall.lua @@ -0,0 +1,27 @@ +-- 1. get the config for this server from nvim-lspconfig and adjust the cmd path. +-- relative paths are allowed, lspinstall automatically adjusts the cmd and cmd_cwd for us! +local config = require'lspconfig'.jdtls.document_config +require'lspconfig/configs'.jdtls = nil -- important, unset the loaded config again +-- config.default_config.cmd[1] = "./node_modules/.bin/bash-language-server" + +-- 2. extend the config with an install_script and (optionally) uninstall_script +require'lspinstall/servers'.jdtls = vim.tbl_extend('error', config, { + -- lspinstall will automatically create/delete the install directory for every server + install_script = [[ + git clone https://github.com/eclipse/eclipse.jdt.ls.git + cd eclipse.jdt.ls + ./mvnw clean verify + ]], + uninstall_script = nil -- can be omitted +}) + +require'lspinstall/servers'.kotlin = vim.tbl_extend('error', config, { + install_script = [[ + git clone https://github.com/fwcd/kotlin-language-server.git language-server + cd language-server + ./gradlew :server:installDist + ]], + uninstall_script = nil -- can be omitted +}) + +require'lspinstall'.setup() diff --git a/nvim/lua/pluginconfig/numb.lua b/nvim/lua/pluginconfig/numb.lua new file mode 100644 index 0000000..415327f --- /dev/null +++ b/nvim/lua/pluginconfig/numb.lua @@ -0,0 +1,4 @@ +require('numb').setup{ + show_numbers = true, -- Enable 'number' for the window while peeking + show_cursorline = true -- Enable 'cursorline' for the window while peeking +} diff --git a/nvim/lua/pluginconfig/nvim-autopairs.lua b/nvim/lua/pluginconfig/nvim-autopairs.lua new file mode 100644 index 0000000..8a26f13 --- /dev/null +++ b/nvim/lua/pluginconfig/nvim-autopairs.lua @@ -0,0 +1,123 @@ +-- require('nvim-autopairs').setup() +-- local npairs = require('nvim-autopairs') + +-- local function imap(lhs, rhs, opts) +-- local options = {noremap = false} +-- if opts then options = vim.tbl_extend('force', options, opts) end +-- vim.api.nvim_set_keymap('i', lhs, rhs, options) +-- end + +-- _G.MUtils = {} + +-- -- TEST +-- vim.g.completion_confirm_key = "" +-- MUtils.completion_confirm = function() +-- if vim.fn.pumvisible() ~= 0 then +-- if vim.fn.complete_info()["selected"] ~= -1 then +-- vim.fn["compe#confirm"]() +-- -- return npairs.esc("") +-- return npairs.esc("") +-- else +-- vim.defer_fn(function() +-- vim.fn["compe#confirm"]("") +-- end, 20) +-- return npairs.esc("") +-- end +-- else +-- return npairs.check_break_line_char() +-- end +-- end +-- -- TEST + +-- MUtils.completion_confirm = function() +-- if vim.fn.pumvisible() ~= 0 then +-- if vim.fn.complete_info()["selected"] ~= -1 then +-- vim.fn["compe#confirm"]() +-- return npairs.esc("") +-- else +-- vim.api.nvim_select_popupmenu_item(0, false, false, {}) +-- vim.fn["compe#confirm"]() +-- return npairs.esc("") +-- end +-- else +-- return npairs.check_break_line_char() +-- end +-- end + +-- MUtils.tab = function() +-- if vim.fn.pumvisible() ~= 0 then +-- return npairs.esc("") +-- else +-- if vim.fn["vsnip#available"](1) ~= 0 then +-- vim.fn.feedkeys(string.format('%c%c%c(vsnip-expand-or-jump)', 0x80, 253, 83)) +-- return npairs.esc("") +-- else +-- return npairs.esc("") +-- end +-- end +-- end + +-- MUtils.s_tab = function() +-- if vim.fn.pumvisible() ~= 0 then +-- return npairs.esc("") +-- else +-- if vim.fn["vsnip#jumpable"](-1) ~= 0 then +-- vim.fn.feedkeys(string.format('%c%c%c(vsnip-jump-prev)', 0x80, 253, 83)) +-- return npairs.esc("") +-- else +-- return npairs.esc("") +-- end +-- end +-- end + +-- -- Autocompletion and snippets +-- vim.api.nvim_set_keymap('i', '', 'v:lua.MUtils.completion_confirm()', {expr = true, noremap = true}) +-- -- imap("", "v:lua.MUtils.completion_confirm()", {expr = true, noremap = true}) +-- imap("", "v:lua.MUtils.tab()", {expr = true, noremap = true}) +-- imap("", "v:lua.MUtils.s_tab()", {expr = true, noremap = true}) + +local remap = vim.api.nvim_set_keymap +local npairs = require('nvim-autopairs') +local Rule = require('nvim-autopairs.rule') + +-- skip it, if you use another global object +_G.MUtils= {} + +vim.g.completion_confirm_key = "" +MUtils.completion_confirm=function() + if vim.fn.pumvisible() ~= 0 then + if vim.fn.complete_info()["selected"] ~= -1 then + return vim.fn["compe#confirm"](npairs.esc("")) + else + return npairs.esc("") + end + else + return npairs.autopairs_cr() + end +end + + +remap('i' , '','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true}) + +npairs.setup({ + check_ts = true, + ts_config = { + lua = {'string'},-- it will not add pair on that treesitter node + javascript = {'template_string'}, + java = false,-- don't check treesitter on java + } +}) + +require('nvim-treesitter.configs').setup { + autopairs = {enable = true} +} + +local ts_conds = require('nvim-autopairs.ts-conds') + +-- press % => %% is only inside comment or string +npairs.add_rules({ + Rule("%", "%", "lua") + :with_pair(ts_conds.is_ts_node({'string','comment'})), + Rule("$", "$", "lua") + :with_pair(ts_conds.is_not_ts_node({'function'})) +}) diff --git a/nvim/lua/pluginconfig/nvim-colorizer.lua b/nvim/lua/pluginconfig/nvim-colorizer.lua new file mode 100644 index 0000000..ed8fd40 --- /dev/null +++ b/nvim/lua/pluginconfig/nvim-colorizer.lua @@ -0,0 +1,13 @@ +require'colorizer'.setup( + {'*';}, + { + RGB = true; -- #RGB hex codes + RRGGBB = true; -- #RRGGBB hex codes + RRGGBBAA = true; -- #RRGGBBAA hex codes + rgb_fn = true; -- CSS rgb() and rgba() functions + hsl_fn = true; -- CSS hsl() and hsla() functions + css = true; -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = true; -- Enable all CSS *functions*: rgb_fn, hsl_fn + }) + -- names = true; -- "Name" codes like Blue + diff --git a/nvim/lua/pluginconfig/nvim-compe.lua b/nvim/lua/pluginconfig/nvim-compe.lua new file mode 100644 index 0000000..2070e14 --- /dev/null +++ b/nvim/lua/pluginconfig/nvim-compe.lua @@ -0,0 +1,150 @@ +vim.o.completeopt = "menuone,noselect" + +require'compe'.setup { + enabled = true, + autocomplete = true, + debug = false, + min_length = 1, + preselect = 'enable', + throttle_time = 80, + source_timeout = 200, + incomplete_delay = 400, + max_abbr_width = 100, + max_kind_width = 100, + max_menu_width = 100, + documentation = true, + + source = { + path = {kind = "  (Path)"}, + buffer = {kind = "  (Buffer)"}, + calc = {kind = "  (Calc)"}, + vsnip = {kind = "  (Snippet)"}, + nvim_lsp = {kind = "  (LSP)"}, + -- nvim_lua = {kind = "  "}, + nvim_lua = false, + spell = {kind = "  (Spell)"}, + tags = false, + vim_dadbod_completion = true, + -- snippets_nvim = {kind = "  "}, + -- ultisnips = {kind = "  "}, + -- treesitter = {kind = "  "}, + emoji = {kind = " ﲃ (Emoji)", filetypes={"markdown", "text"}} + -- for emoji press : (idk if that in compe tho) + } +} + +--  +--  +--  +--  +--  +--  +--  +--  +--  +--  +--  +--  +--  +--  +--  +--  +-- ﬘ +--  +--  +--  +-- m +--  +--  +--  +--  + +-- local t = function(str) +-- return vim.api.nvim_replace_termcodes(str, true, true, true) +-- end + +-- local check_back_space = function() +-- local col = vim.fn.col('.') - 1 +-- if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then +-- return true +-- else +-- return false +-- end +-- end + +-- -- Use (s-)tab to: +-- --- move to prev/next item in completion menuone +-- --- jump to prev/next snippet's placeholder +-- _G.tab_complete = function() +-- if vim.fn.pumvisible() == 1 then +-- return t "" +-- elseif vim.fn.call("vsnip#available", {1}) == 1 then +-- return t "(vsnip-expand-or-jump)" +-- elseif check_back_space() then +-- return t "" +-- else +-- return vim.fn['compe#complete']() +-- end +-- end +-- _G.s_tab_complete = function() +-- if vim.fn.pumvisible() == 1 then +-- return t "" +-- elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then +-- return t "(vsnip-jump-prev)" +-- else +-- return t "" +-- end +-- end + +-- vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) +-- vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) +-- vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) +-- vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) + + + + + + + +local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end + +local check_back_space = function() + local col = vim.fn.col('.') - 1 + if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + return true + else + return false + end +end + +-- Use (s-)tab to: +--- move to prev/next item in completion menuone +--- jump to prev/next snippet's placeholder +_G.tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t "" + elseif vim.fn.call("vsnip#available", {1}) == 1 then + return t "(vsnip-expand-or-jump)" + elseif check_back_space() then + return t "" + else + return vim.fn['compe#complete']() + end +end +_G.s_tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t "" + elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then + return t "(vsnip-jump-prev)" + else + return t "" + end +end + +vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) diff --git a/nvim/lua/pluginconfig/nvim-tree.lua b/nvim/lua/pluginconfig/nvim-tree.lua new file mode 100644 index 0000000..30af1d2 --- /dev/null +++ b/nvim/lua/pluginconfig/nvim-tree.lua @@ -0,0 +1,75 @@ +local tree_cb = require'nvim-tree.config'.nvim_tree_callback +require'nvim-tree'.setup { + disable_netrw = true, + hijack_netrw = true, + auto_close = false, + filters = { + dotfiles = false, + custom = {} + }, + git = { + enable = true, + ignore = false, + timeout = 500, + }, + update_focused_file = { + -- enables the feature + enable = false, + -- update the root directory of the tree to the one of the folder containing the file if the file is not under the current root directory + -- only relevant when `update_focused_file.enable` is true + update_cwd = false, + -- list of buffer names / filetypes that will not update the cwd if the file isn't found under the current root directory + -- only relevant when `update_focused_file.update_cwd` is true and `update_focused_file.enable` is true + ignore_list = {} + }, + view = { + mappings = { + custome_only= false, + list = { + -- [""] = ":YourVimFunction()", + -- ["u"] = ":lua require'some_module'.some_function()", + + -- default mappings + {key="" ,cb= tree_cb("edit")}, + {key="o" ,cb= tree_cb("edit")}, + {key="l" ,cb= tree_cb("edit")}, + {key="<2-LeftMouse>" ,cb= tree_cb("edit")}, + {key="<2-RightMouse>" ,cb= tree_cb("cd")}, + {key="" ,cb= tree_cb("cd")}, + {key="v" ,cb= tree_cb("vsplit")}, + {key="s" ,cb= tree_cb("split")}, + {key="" ,cb= tree_cb("tabnew")}, + {key="<" ,cb= tree_cb("prev_sibling")}, + {key=">" ,cb= tree_cb("next_sibling")}, + {key="" ,cb= tree_cb("close_node")}, + {key="h" ,cb= tree_cb("close_node")}, + {key="" ,cb= tree_cb("close_node")}, + {key="" ,cb= tree_cb("preview")}, + {key="I" ,cb= tree_cb("toggle_ignored")}, + {key="H" ,cb= tree_cb("toggle_dotfiles")}, + {key="R" ,cb= tree_cb("refresh")}, + {key="a" ,cb= tree_cb("create")}, + {key="d" ,cb= tree_cb("remove")}, + {key="r" ,cb= tree_cb("rename")}, + {key="" ,cb= tree_cb("full_rename")}, + {key="x" ,cb= tree_cb("cut")}, + {key="c" ,cb= tree_cb("copy")}, + {key="p" ,cb= tree_cb("paste")}, + {key="[c" ,cb= tree_cb("prev_git_item")}, + {key="c" ,cb= tree_cb("next_git_item")}, + {key="-" ,cb= tree_cb("dir_up")}, + {key="q" ,cb= tree_cb("close")}, + } + } + } +} + +vim.g.nvim_tree_indent_markers = 1 -- "0 by default, this option shows indent markers when folders are open +vim.g.nvim_tree_auto_ignore_ft = 'startify' --empty by default, don't auto open tree on specific filetypes. + +vim.g.nvim_tree_icons = { + default = '', + symlink = '', + git = {unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = ""}, + folder = {default = "", open = "", empty = "", empty_open = "", symlink = ""} +} diff --git a/nvim/lua/pluginconfig/nvim-treesitter.lua b/nvim/lua/pluginconfig/nvim-treesitter.lua new file mode 100644 index 0000000..157afa9 --- /dev/null +++ b/nvim/lua/pluginconfig/nvim-treesitter.lua @@ -0,0 +1,30 @@ +local treesitter = { + ensure_installed = "all", + ignore_install = {"haskell"}, + highlight = {enabled = true}, + playground = {enabled = true}, + rainbow = {enabled = false}, +} + +require'nvim-treesitter.configs'.setup { + ensure_installed = treesitter.ensure_installed, -- one of "all", "maintained" (parsers with maintainers), or a list of languages + ignore_install = treesitter.ignore_install, + matchup = { + enable = true, -- mandatory, false will disable the whole extension + -- disable = { "c", "ruby" }, -- optional, list of language that will be disabled + }, + highlight = { + enable = treesitter.highlight.enabled -- false will disable the whole extension + }, + context_commentstring = { + enable = true, + config = { + css = '// %s' + } + }, + -- indent = {enable = true, disable = {"python", "html", "javascript"}}, + -- TODO seems to be broken + indent = {enable = {"javascriptreact"}}, + autotag = {enable = true}, +} + diff --git a/nvim/lua/pluginconfig/rnvimr.lua b/nvim/lua/pluginconfig/rnvimr.lua new file mode 100644 index 0000000..c1140a7 --- /dev/null +++ b/nvim/lua/pluginconfig/rnvimr.lua @@ -0,0 +1,6 @@ +-- Make Ranger replace netrw and be the file explorer +-- vim.g.rnvimr_ex_enable = 1 +vim.g.rnvimr_draw_border = 1 +vim.g.rnvimr_pick_enable = 1 +vim.g.rnvimr_bw_enable = 1 +vim.api.nvim_set_keymap('n', '-', ':RnvimrToggle', {noremap = true, silent = true}) diff --git a/nvim/lua/pluginconfig/symbols-outline.lua b/nvim/lua/pluginconfig/symbols-outline.lua new file mode 100644 index 0000000..63fb2cf --- /dev/null +++ b/nvim/lua/pluginconfig/symbols-outline.lua @@ -0,0 +1,15 @@ +vim.g.symbols_outline = { + highlight_hovered_item = true, + show_guides = true, + auto_preview = true, + position = 'right', + keymaps = { + close = "", + goto_location = "", + focus_location = "o", + hover_symbol = "", + rename_symbol = "r", + code_actions = "a", + }, + lsp_blacklist = {}, +} diff --git a/nvim/lua/pluginconfig/telescope.lua b/nvim/lua/pluginconfig/telescope.lua new file mode 100644 index 0000000..ce39b63 --- /dev/null +++ b/nvim/lua/pluginconfig/telescope.lua @@ -0,0 +1,81 @@ +local actions = require('telescope.actions') +local trouble = require("trouble.providers.telescope") +-- Global remapping +------------------------------ +-- '--color=never', +require('telescope').setup { + defaults = { + --find_command = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'}, + vimgrep_arguments = { 'rg', '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case' }, + -- prompt_prefix = " ", + prompt_prefix = " ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + -- initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "descending", + layout_strategy = "horizontal", + layout_config= {horizontal = {mirror = false}, vertical = {mirror = false}, width = 0.75,prompt_position = "bottom", preview_cutoff = 120}, + file_sorter = require'telescope.sorters'.get_fzy_sorter, + file_ignore_patterns = {}, + generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter, + -- shorten_path = true, + path_display = {shroten = 2}, + winblend = 0, + border = {}, + borderchars = {'─', '│', '─', '│', '╭', '╮', '╯', '╰'}, + color_devicons = true, + use_less = true, + set_env = {['COLORTERM'] = 'truecolor'}, -- default = nil, + file_previewer = require'telescope.previewers'.vim_buffer_cat.new, + grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, + qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new, + + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker, + mappings = { + i = { + [""] = actions.close, + [""] = actions.close, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = trouble.open_with_trouble, + [""] = actions.smart_send_to_qflist + actions.open_qflist, + -- To disable a keymap, put [map] = false + -- So, to not map "", just put + -- [""] = false, + -- [""] = actions.close, + + -- Otherwise, just set the mapping to the function that you want it to be. + -- [""] = actions.select_horizontal, + + -- Add up multiple actions + [""] = actions.select_default + actions.center + + -- You can perform as many actions in a row as you like + -- [""] = actions.select_default + actions.center + my_cool_custom_action, + }, + n = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = trouble.open_with_trouble, + [""] = actions.smart_send_to_qflist + actions.open_qflist + -- [""] = my_cool_custom_action, + } + } + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + } + } +} + +--require('telescope').load_extension('fzf') +require'telescope'.load_extension('project') +require("telescope").load_extension "file_browser" diff --git a/nvim/lua/pluginconfig/toggleterm.lua b/nvim/lua/pluginconfig/toggleterm.lua new file mode 100644 index 0000000..f14a0c2 --- /dev/null +++ b/nvim/lua/pluginconfig/toggleterm.lua @@ -0,0 +1,50 @@ +require("toggleterm").setup{ + -- size can be a number or function which is passed the current terminal + size = function(term) + if term.direction == "horizontal" then + return 15 + elseif term.direction == "vertical" then + return vim.o.columns * 0.4 + end + end, + open_mapping = [[]], + hide_numbers = true, -- hide the number column in toggleterm buffers + shade_filetypes = {}, + shade_terminals = true, + shading_factor = '', -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light + start_in_insert = true, + insert_mappings = true, -- whether or not the open mapping applies in insert mode + persist_size = true, + -- direction = 'vertical' | 'horizontal' | 'window' | 'float', + direction = 'float', + close_on_exit = true, -- close the terminal window when the process exits + shell = vim.o.shell, -- change the default shell + -- This field is only relevant if direction is set to 'float' + float_opts = { + -- The border key is *almost* the same as 'nvim_open_win' + -- see :h nvim_open_win for details on borders however + -- the 'curved' border is a custom border type + -- not natively supported but implemented in this plugin. + -- border = 'single' | 'double' | 'shadow' | 'curved' -- ... other options supported by win open + border = 'single', + -- width = , + -- height = , + winblend = 3, + highlights = { + border = "Normal", + background = "Normal", + } + } + } + +-- function _G.set_terminal_keymaps() +-- local opts = {noremap = true} +-- vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) +-- vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[]], opts) +-- vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) +-- vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) +-- vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) +-- vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) +-- end + +-- vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') diff --git a/nvim/lua/pluginconfig/vim-matchup.lua b/nvim/lua/pluginconfig/vim-matchup.lua new file mode 100644 index 0000000..27b3f57 --- /dev/null +++ b/nvim/lua/pluginconfig/vim-matchup.lua @@ -0,0 +1,2 @@ +vim.g.matchup_matchparen_offscreen = {method = 'popup'} + diff --git a/nvim/lua/pluginconfig/which-key.lua b/nvim/lua/pluginconfig/which-key.lua new file mode 100644 index 0000000..b3129ec --- /dev/null +++ b/nvim/lua/pluginconfig/which-key.lua @@ -0,0 +1,243 @@ +require("which-key").setup { + plugins = { + marks = true, -- shows a list of your marks on ' and ` + registers = true, -- shows your registers on " in NORMAL or in INSERT mode + -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- No actual key bindings are created + presets = { + operators = false, -- adds help for operators like d, y, ... + motions = false, -- adds help for motions + text_objects = false, -- help for text objects triggered after entering an operator + windows = true, -- default bindings on + nav = true, -- misc bindings to work with windows + z = true, -- bindings for folds, spelling and others prefixed with z + g = true -- bindings for prefixed with g + } + }, + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "➜", -- symbol used between a key and it's label + group = "+" -- symbol prepended to a group + }, + window = { + border = "single", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = {1, 0, 1, 0}, -- extra window margin [top, right, bottom, left] + padding = {2, 2, 2, 2} -- extra window padding [top, right, bottom, left] + }, + layout = { + height = {min = 4, max = 25}, -- min and max height of the columns + width = {min = 20, max = 50}, -- min and max width of the columns + spacing = 3 -- spacing between columns + }, + hidden = {"", "", "", "", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate + show_help = true -- show help message on the command line when the popup is visible +} + +local opts = { + mode = "n", -- NORMAL mode + prefix = "", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = false -- use `nowait` when creating keymaps +} + +-- Set leader +vim.api.nvim_set_keymap('n', '', '', {noremap = true, silent = true}) +vim.g.mapleader = ' ' + +-- no hl +vim.api.nvim_set_keymap('n', 'h', ':set hlsearch!', {noremap = true, silent = true}) + +-- explorer +vim.api.nvim_set_keymap('n', 'e', ':NvimTreeToggle', {noremap = true, silent = true}) + +-- telescope +--vim.api.nvim_set_keymap('n', '', ":lua require 'telescope'.extensions.file_browser.file_browser()", {noremap = true, silent = true}) +-- vim.api.nvim_set_keymap('n', '', ":lua require'telescope.builtin'.find_files()", {noremap = true, silent = true}) +vim.api.nvim_set_keymap('n', '', ":FzfLua files", {noremap = true, silent = true}) + +-- dashboard +vim.api.nvim_set_keymap('n', ';', ':Dashboard', {noremap = true, silent = true}) + +-- Comments +vim.api.nvim_set_keymap("n", "b/", ":CommentToggle", {noremap = true, silent = true}) +vim.api.nvim_set_keymap("v", "b/", ":CommentToggle", {noremap = true, silent = true}) + +-- close buffer +vim.api.nvim_set_keymap("n", "c", ":BufferClose", {noremap = true, silent = true}) + +-- open projects +--vim.api.nvim_set_keymap('n', 'p', ":lua require'telescope'.extensions.project.project{}", {noremap = true, silent = true}) +-- vim.api.nvim_set_keymap('n', 'p', ":lua require 'telescope'.extensions.file_browser.file_browser()", {noremap = true, silent = true}) +-- TODO create entire treesitter section + +local mappings = { + -- ["/"] = "Comment", + -- ["c"] = "Close Buffer", + ["e"] = "Explorer", + -- ["f"] = "Find File", + ["h"] = "No Highlight", + a = { + name = "+Action", + a = {"@:","execute last command again"} + }, + b = { + name = "+Buffer", + n = {"BufferNext", "next buffer"}, + p = {"BufferPrevious", "previous buffer"}, + q = {"q", "quit"}, + s = {"w", "save"}, + r = {"e!", "reload"}, + d = {"BufferClose", "close buffer"}, + z = {"CommentToggle", "toggle comment"}, + }, + D = { + name = "+Diagnostics", + t = {"TroubleToggle", "trouble"}, + w = {"TroubleToggle lsp_workspace_diagnostics", "workspace"}, + d = {"TroubleToggle lsp_document_diagnostics", "document"}, + q = {"TroubleToggle quickfix", "quickfix"}, + l = {"TroubleToggle loclist", "loclist"}, + r = {"TroubleToggle lsp_references", "references"}, + }, + d = { + name = "+Debug", + -- b = {"DebugToggleBreakpoint", "Toggle Breakpoint"}, + -- c = {"DebugContinue", "Continue"}, + -- i = {"DebugStepInto", "Step Into"}, + -- o = {"DebugStepOver", "Step Over"}, + -- r = {"DebugToggleRepl", "Toggle Repl"}, + -- s = {"DebugStart", "Start"} + d = {"lua vim.lsp.diagnostic.show_line_diagnostics()", "show diagnostics"}, + + c = {"lua require'dap'.continue()", "continue"}, + b = {':lua require"dap".toggle_breakpoint()', "Toggle Breadpoint"}, + j = {':lua require"dap".step_over()', "step over"}, + k = {':lua require"dap".step_out()', "step out"}, + l = {':lua require"dap".step_into()',"step into"}, + --', ':lua require"dap".continue()') + u = {':lua require"dap".up()', "up"}, + -- d = {':lua require"dap".down()', "down"}, + _ = {':lua require"dap".disconnect();require"dap".stop();require"dap".run_last()', "disconnect"}, + --r = {':lua require"dap".repl.open({}, "vsplit")l', "repl open"}, + i = {':lua require"dap.ui.variables".visual_hover()',"visual_hover"}, + --? = {':lua require"dap.ui.variables".scopes()',"scopes"}, + -- e = {':lua require"dap".set_exception_breakpoints({"all"})',"esception bp"}, + -- a = {':lua require"debugHelper".attach()',"attach"}, + -- A = {':lua require"debugHelper".attachToRemote()',"attach to remote"}, + s = {':lua local widgets=require"dap.ui.widgets";widgets.centered_float(widgets.scopes)',"centered_float"}, + }, + f = { + name = "+File", + s = {"w", "save file"}, + t = {"NvimTreeToggle", "toggle nvim tree"}, + r = {"RnvimrToggle", "toggle rnvimr"}, + y = {"lua require'utils'.yank_filepath()", "copy the file path"}, + l = {"NvimTreeFindFile", "find file"}, + -- T = {"let @+ = 'go test -v -run='+expand('')", "get current word in go test"}, + }, + g = { + name = "+Git", + j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, + k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, + l = { "lua require 'gitsigns'.blame_line()", "Blame" }, + p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, + r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, + R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, + s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, + u = { + "lua require 'gitsigns'.undo_stage_hunk()", + "Undo Stage Hunk", + }, + o = { "Telescope git_status", "Open changed file" }, + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope git_commits", "Checkout commit" }, + C = { + "Telescope git_bcommits", + "Checkout commit(for current file)", + }, + d = { + "Gitsigns diffthis HEAD", + "Git Diff", + }, + }, + l = { + name = "+Language", + a = {"Lspsaga code_action", "Code Action"}, + A = {"Lspsaga range_code_action", "Selected Action"}, + d = {"Telescope lsp_document_diagnostics", "Document Diagnostics"}, + D = {"Telescope lsp_workspace_diagnostics", "Workspace Diagnostics"}, + f = {"LspFormatting", "Format"}, + -- i = {"Telescope lsp_implementations", "implement"}, + i = {"lua vim.lsp.buf.implementation()", "implement"}, + F = {"Lspsaga lsp_finder", "LSP Finder"}, + L = {"Lspsaga show_line_diagnostics", "Line Diagnostics"}, + l = {"lua vim.lsp.buf.hover()", "hover"}, + P = {"Lspsaga preview_definition", "Preview Definition"}, + n = {"lua vim.lsp.diagnostic.goto_next()", "next diagnostic"}, + p = {"lua vim.lsp.diagnostic.goto_prev()", "prev diagnostic"}, + q = {"Telescope quickfix", "Quickfix"}, + r = {"lua vim.lsp.buf.references()", "references"}, + R = {"Lspsaga rename", "Rename"}, + t = {"LspTypeDefinition", "Type Definition"}, + x = {"cclose", "Close Quickfix"}, + s = {"Telescope lsp_document_symbols", "Document Symbols"}, + S = {"Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols"}, + z = {"LspInfo", "Info"}, + }, + p = { + name = "Packer", + c = { "PackerCompile", "Compile" }, + i = { "PackerInstall", "Install" }, + s = { "PackerSync", "Sync" }, + S = { "PackerStatus", "Status" }, + u = { "PackerUpdate", "Update" }, + }, + q = { + name = "quit", + q = {"qall", "quit"}, + }, + s = { + name = "+Search", + b = {"Telescope git_branches", "Checkout branch"}, + -- c = {"Telescope colorscheme", "Colorscheme"}, + c = {":nohl", "no highlight"}, + d = {"Telescope lsp_document_diagnostics", "Document Diagnostics"}, + D = {"Telescope lsp_workspace_diagnostics", "Workspace Diagnostics"}, + f = {"Fzflua files", "Find File"}, + m = {"Telescope marks", "Marks"}, + M = {"Telescope man_pages", "Man Pages"}, + r = {"FzfLua oldfiles", "Open Recent File"}, + R = {"Telescope registers", "Registers"}, + t = {"FzfLua live_grep", "Text"}, + ["#"] = {"FzfLua grep_cword", "Search word under cursor"}, + }, + S = { + name = "+Session", + s = {"SessionSave", "Save Session"}, + l = {"SessionLoad", "Load Session"}, + }, + t = { + name = "+Test", + a = {"TestSuite -v -cover", "TestSuite"}, + t = {"TestNearest -v -cover", "TestNearest"}, + f = {"TestFile -v -cover", "TestFile"}, + c = {"GoCover", "go coverage"}, + C = {"GoCoverClear", "go coverage clear"}, + b = {"lua require'dap'.toggle_breakpoint()", "set break point"}, + r = {"lua require'dap'.continue()", "continue"}, + }, + + -- extras + z = { + name = "+Zen", + s = {"TZBottom", "toggle status line"}, + t = {"TZTop", "toggle tab bar"}, + z = {"TZAtaraxis", "toggle zen"}, + } +} + +local wk = require("which-key") +wk.register(mappings, opts) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua new file mode 100644 index 0000000..a69ce1e --- /dev/null +++ b/nvim/lua/plugins.lua @@ -0,0 +1,211 @@ +local execute = vim.api.nvim_command +local fn = vim.fn + +local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" + +if fn.empty(fn.glob(install_path)) > 0 then + execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path) + execute "packadd packer.nvim" +end + +--- Check if a file or directory exists in this path +local function require_plugin(plugin) + local plugin_prefix = fn.stdpath("data") .. "/site/pack/packer/opt/" + + local plugin_path = plugin_prefix .. plugin .. "/" + -- print('test '..plugin_path) + local ok, err, code = os.rename(plugin_path, plugin_path) + if not ok then + if code == 13 then + -- Permission denied, but it exists + return true + end + end + if ok then vim.cmd("packadd " .. plugin) end + if not ok then + print(ok, err, code) + end + return ok, err, code +end + +vim.cmd "autocmd BufWritePost plugins.lua PackerCompile" -- Auto compile when there are changes in plugins.lua + +return require("packer").startup(function(use) + -- Packer can manage itself as an optional plugin + use "wbthomason/packer.nvim" + + -- TODO refactor all of this (for now it works, but yes I know it could be wrapped in a simpler function) + use {"neovim/nvim-lspconfig", opt = true} + use {'tami5/lspsaga.nvim', branch = 'nvim6.0', opt=true} + use {"kabouzeid/nvim-lspinstall", opt = true} + use {"folke/trouble.nvim", opt = true} + + -- Telescope + use {"nvim-lua/popup.nvim", opt = true} + use {"nvim-lua/plenary.nvim", opt = true} + use {"nvim-telescope/telescope.nvim", opt = true} + use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } + use {"nvim-telescope/telescope-project.nvim", opt = true} + use { "nvim-telescope/telescope-file-browser.nvim" } + + use { 'ibhagwan/fzf-lua', + -- optional for icon support + requires = { 'kyazdani42/nvim-web-devicons' } + } + + use {'folke/lua-dev.nvim'} + use {"rafcamlet/nvim-luapad"} + + -- Debugging + use {"mfussenegger/nvim-dap", opt = true} + + -- Autocomplete + use {"hrsh7th/nvim-compe", opt = true} + use {"hrsh7th/vim-vsnip", opt = true} + use {"rafamadriz/friendly-snippets", opt = true} + + -- Treesitter + use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"} + use {"windwp/nvim-ts-autotag", opt = true} + use {'andymass/vim-matchup', opt = true} + + -- Explorer + use { + 'kyazdani42/nvim-tree.lua', + requires = 'kyazdani42/nvim-web-devicons', + opt = true, + config = function() require'nvim-tree'.setup {} end + } + use {"ahmedkhalf/lsp-rooter.nvim", opt = true} -- with this nvim-tree will follow you + -- TODO remove when open on dir is supported by nvimtree + use "kevinhwang91/rnvimr" + + -- use {'lukas-reineke/indent-blankline.nvim', opt=true, branch = 'lua'} + use { 'lewis6991/gitsigns.nvim', opt = true, requires = { 'nvim-lua/plenary.nvim' } } + use {"folke/which-key.nvim", opt = true} + use {"ChristianChiarulli/dashboard-nvim", opt = true} + use {"windwp/nvim-autopairs", opt = true} + use {"kevinhwang91/nvim-bqf", opt = true} + + -- Comments + use {"terrortylor/nvim-comment", opt = true} + use {'JoosepAlviste/nvim-ts-context-commentstring', opt = true} + + -- Color + use {"christianchiarulli/nvcode-color-schemes.vim", opt = true} + use {"npxbr/gruvbox.nvim", requires = {"rktjmp/lush.nvim"}} + + -- Icons + use {"kyazdani42/nvim-web-devicons", opt = true} + + -- Status Line and Bufferline + use {"glepnir/galaxyline.nvim", opt = true} + use {"romgrk/barbar.nvim", opt = true} + + -- Go plugin + -- use {"fatih/vim-go", run= ":GoUpdateBinaries"} + -- use {"fatih/vim-go", run = ":GoUpdateBinaries", ft = "go"} + -- require_plugin("fatih/vim-go") + -- debuger + use {"puremourning/vimspector", opt=true} + require_plugin("vimspector") + + -- vim test + use {"vim-test/vim-test", opt=true} + require_plugin("vim-test") + use {"kyoh86/vim-go-coverage", opt=true, ft="go"} + require_plugin("vim-go-coverage") + use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } + + -- Sane gx for netrw_gx bug + -- use {"felipec/vim-sanegx"} + + + require_plugin("nvim-lspconfig") + require_plugin("lspsaga.nvim") + require_plugin("nvim-lspinstall") + require_plugin('trouble.nvim') + require_plugin("friendly-snippets") + require_plugin("popup.nvim") + require_plugin("plenary.nvim") + require_plugin("telescope.nvim") + require_plugin('telescope-project.nvim') + require_plugin("nvim-dap") + require_plugin("nvim-compe") + require_plugin("vim-vsnip") + -- require_plugin("nvim-treesitter") + require_plugin("nvim-ts-autotag") + require_plugin('vim-matchup') + require_plugin("nvim-tree.lua") + require_plugin("gitsigns.nvim") + require_plugin("which-key.nvim") + require_plugin("dashboard-nvim") + require_plugin("nvim-autopairs") + require_plugin("nvim-comment") + require_plugin("nvim-bqf") + require_plugin("nvcode-color-schemes.vim") + require_plugin("nvim-web-devicons") + require_plugin("galaxyline.nvim") + require_plugin("barbar.nvim") + require_plugin('lsp-rooter.nvim') + require_plugin("nvim-ts-context-commentstring") + + use {'nvim-telescope/telescope-dap.nvim', opt=true} + require_plugin("telescope-dap.nvim") + use {'theHamsta/nvim-dap-virtual-text', opt=true} + require_plugin("nvim-dap-virtual-text") + + use { "ray-x/lsp_signature.nvim"} + use 'tanvirtin/monokai.nvim' + use 'fratajczak/one-monokai-vim' + use {"npxbr/glow.nvim", run = "GlowInstall"} + + use {"akinsho/nvim-toggleterm.lua"} + use {"Pocco81/DAPInstall.nvim", opt=true} + require_plugin("DAPInstall.nvim") + + --use 'EdenEast/nightfox.nvim' + -- use {'godlygeek/tabular', opt=true} + -- use {'plasticboy/vim-markdown', opt=true} + -- require_plugin("tabular") + -- require_plugin("vim-markdown") + + -- Extras + if O.extras then + use {'metakirby5/codi.vim', opt = true} + require_plugin('codi.vim') + --use {'iamcco/markdown-preview.nvim', run = 'cd app && npm install', opt = true} + --require_plugin('markdown-preview.nvim') + use {'numToStr/FTerm.nvim', opt = true} + require_plugin('FTerm.nvim') + use {'nacro90/numb.nvim', opt = true} + require_plugin('numb.nvim') + use {'turbio/bracey.vim', run = 'npm install --prefix server', opt = true} + require_plugin('bracey.vim') + use {'phaazon/hop.nvim', opt = true} + require_plugin('hop.nvim') + use {'norcalli/nvim-colorizer.lua', opt = true} + require_plugin('nvim-colorizer.lua') + use {'windwp/nvim-spectre', opt = true} + require_plugin('nvim-spectre') + use {'simrat39/symbols-outline.nvim', opt = true} + require_plugin('symbols-outline.nvim') + use {'nvim-treesitter/playground', opt = true} + require_plugin('playground') + -- folke/todo-comments.nvim + -- gennaro-tedesco/nvim-jqx + -- TimUntersberger/neogit + -- folke/lsp-colors.nvim + -- simrat39/symbols-outline.nvim + + -- Git + -- use {'tpope/vim-fugitive', opt = true} + -- use {'tpope/vim-rhubarb', opt = true} + -- pwntester/octo.nvim + + -- Easily Create Gists + -- use {'mattn/vim-gist', opt = true} + -- use {'mattn/webapi-vim', opt = true} + end + +end) diff --git a/nvim/lua/pluginsList/lua.lua b/nvim/lua/pluginsList/lua.lua deleted file mode 100644 index 4edb5ad..0000000 --- a/nvim/lua/pluginsList/lua.lua +++ /dev/null @@ -1,36 +0,0 @@ --- check if packer is installed (~/local/share/nvim/site/pack) -local packer_exists = pcall(vim.cmd, [[packadd packer.nvim]]) - -return require("packer").startup( - function() - use {"wbthomason/packer.nvim", opt = true} - use {"kyazdani42/nvim-web-devicons"} - use {"kyazdani42/nvim-tree.lua"} - use {"nvim-lua/plenary.nvim"} - use {"lewis6991/gitsigns.nvim"} - use {"glepnir/galaxyline.nvim"} - use {"akinsho/nvim-bufferline.lua"} - use {"907th/vim-auto-save"} - use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"} - use {"chriskempson/base16-vim"} - use {"norcalli/nvim-colorizer.lua"} - use {"Yggdroot/indentLine"} - use {"ryanoasis/vim-devicons"} - use {"sbdchd/neoformat"} - use {"neovim/nvim-lspconfig"} - use {"hrsh7th/nvim-compe"} - use {"windwp/nvim-autopairs"} - use {"alvan/vim-closetag"} - use {"tweekmonster/startuptime.vim"} - use {"onsails/lspkind-nvim"} - use {"nvim-telescope/telescope.nvim"} - use {"nvim-telescope/telescope-media-files.nvim"} - use {"nvim-lua/popup.nvim"} - use {"junegunn/fzf"} - use {"junegunn/fzf.vim"} - use {"lyokha/vim-xkbswitch"} - use {"rrethy/vim-hexokinase", run = "make hexokinase"} - use {"doums/darcula"} - use {"christianchiarulli/nvcode-color-schemes.vim"} - end -) diff --git a/nvim/lua/settings.lua b/nvim/lua/settings.lua new file mode 100644 index 0000000..08ea8d4 --- /dev/null +++ b/nvim/lua/settings.lua @@ -0,0 +1,61 @@ +vim.cmd('set iskeyword+=-') -- treat dash separated words as a word text object" +vim.cmd('set shortmess+=c') -- Don't pass messages to |ins-completion-menu|. +vim.cmd('set inccommand=split') -- Make substitution work in realtime +vim.o.hidden = true -- Required to keep multiple buffers open multiple buffers +vim.o.title = true +TERMINAL = vim.fn.expand('$TERMINAL') +vim.cmd('let &titleold="'..TERMINAL..'"') +vim.o.titlestring="%<%F%=%l/%L - nvim" +vim.wo.wrap = false -- Display long lines as just one line +vim.cmd('set whichwrap+=<,>,[,],h,l') -- move to next line with theses keys +vim.cmd('syntax on') -- syntax highlighting +vim.o.pumheight = 10 -- Makes popup menu smaller +vim.o.fileencoding = "utf-8" -- The encoding written to file +vim.o.cmdheight = 2 -- More space for displaying messages +vim.cmd('set colorcolumn=99999') -- fix indentline for now +vim.o.mouse = "a" -- Enable your mouse +vim.o.splitbelow = true -- Horizontal splits will automatically be below +vim.o.termguicolors = true -- set term gui colors most terminals support this +vim.o.splitright = true -- Vertical splits will automatically be to the right +-- vim.o.t_Co = "256" -- Support 256 colors +vim.o.conceallevel = 0 -- So that I can see `` in markdown files +vim.cmd('set ts=4') -- Insert 2 spaces for a tab +vim.cmd('set sw=4') -- Change the number of space characters inserted for indentation +vim.cmd('set expandtab') -- Converts tabs to spaces +vim.bo.smartindent = true -- Makes indenting smart +vim.wo.number = true -- set numbered lines +vim.wo.relativenumber = true -- set relative number +vim.wo.cursorline = true -- Enable highlighting of the current line +vim.o.showtabline = 2 -- Always show tabs +vim.o.showmode = false -- We don't need to see things like -- INSERT -- anymore +vim.o.backup = false -- This is recommended by coc +vim.o.writebackup = false -- This is recommended by coc +vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time +vim.o.updatetime = 300 -- Faster completion +vim.o.timeoutlen = 100 -- By default timeoutlen is 1000 ms +vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else +vim.cmd('filetype plugin on') -- filetype detection +-- vim.o.guifont = "JetBrainsMono\\ Nerd\\ Font\\ Mono:h18" +-- vim.o.guifont = "Hack\\ Nerd\\ Font\\ Mono" +-- vim.o.guifont = "SauceCodePro Nerd Font:h17" +vim.o.guifont = "FiraCode Nerd Font:h17" + +-- vim.o.guifont = "JetBrains\\ Mono\\ Regular\\ Nerd\\ Font\\ Complete" + +vim.g.vimspector_enable_mappings = 'HUMAN' +vim.g['test#go#rspec#options'] = { nearest= '--v', suite= '--v' } +vim.o.background = "dark" +--require('monokai') +--vim.cmd('colorscheme monokai_pro') +--require('nightfox').set() +--vim.cmd('colorscheme one-monokai') +--vim.cmd([[colorscheme gruvbox]]) + +-- git blame +vim.cmd('highlight default link gitblame SpecialComment') +vim.g.gitblame_enabled = 0 + +-- last position jump +vim.cmd([[ +autocmd BufReadPost * if line("'\"") >= 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif +]]) diff --git a/nvim/lua/statusline/lua.lua b/nvim/lua/statusline/lua.lua deleted file mode 100644 index fe0aff8..0000000 --- a/nvim/lua/statusline/lua.lua +++ /dev/null @@ -1,204 +0,0 @@ -local gl = require("galaxyline") -local gls = gl.section -gl.short_line_list = {"LuaTree", "vista", "dbui"} - -local colors = { - bg = "#282c34", - line_bg = "#282c34", - fg = "#D8DEE9", - fg_green = "#65a380", - yellow = "#A3BE8C", - cyan = "#22262C", - darkblue = "#61afef", - green = "#BBE67E", - orange = "#FF8800", - purple = "#252930", - magenta = "#c678dd", - blue = "#22262C", - red = "#DF8890", - lightbg = "#3C4048", - nord = "#81A1C1", - greenYel = "#EBCB8B" -} - -gls.left[1] = { - leftRounded = { - provider = function() - return "" - end, - highlight = {colors.nord, colors.bg} - } -} - -gls.left[2] = { - ViMode = { - provider = function() - return "  " - end, - highlight = {colors.bg, colors.nord}, - separator = " ", - separator_highlight = {colors.lightbg, colors.lightbg} - } -} - -gls.left[3] = { - FileIcon = { - provider = "FileIcon", - condition = buffer_not_empty, - highlight = {require("galaxyline.provider_fileinfo").get_file_icon_color, colors.lightbg} - } -} - -gls.left[4] = { - FileName = { - provider = {"FileName", "FileSize"}, - condition = buffer_not_empty, - highlight = {colors.fg, colors.lightbg} - } -} - -gls.left[5] = { - teech = { - provider = function() - return "" - end, - separator = " ", - highlight = {colors.lightbg, colors.bg} - } -} - -local checkwidth = function() - local squeeze_width = vim.fn.winwidth(0) / 2 - if squeeze_width > 40 then - return true - end - return false -end - -gls.left[6] = { - DiffAdd = { - provider = "DiffAdd", - condition = checkwidth, - icon = "  ", - highlight = {colors.greenYel, colors.line_bg} - } -} - -gls.left[7] = { - DiffModified = { - provider = "DiffModified", - condition = checkwidth, - icon = " ", - highlight = {colors.orange, colors.line_bg} - } -} - -gls.left[8] = { - DiffRemove = { - provider = "DiffRemove", - condition = checkwidth, - icon = " ", - highlight = {colors.red, colors.line_bg} - } -} - -gls.left[9] = { - LeftEnd = { - provider = function() - return " " - end, - separator = " ", - separator_highlight = {colors.line_bg, colors.line_bg}, - highlight = {colors.line_bg, colors.line_bg} - } -} - -gls.left[10] = { - DiagnosticError = { - provider = "DiagnosticError", - icon = "  ", - highlight = {colors.red, colors.bg} - } -} - -gls.left[11] = { - Space = { - provider = function() - return " " - end, - highlight = {colors.line_bg, colors.line_bg} - } -} - -gls.left[12] = { - DiagnosticWarn = { - provider = "DiagnosticWarn", - icon = "  ", - highlight = {colors.blue, colors.bg} - } -} - -gls.right[1] = { - GitIcon = { - provider = function() - return "  " - end, - condition = require("galaxyline.provider_vcs").check_git_workspace, - highlight = {colors.green, colors.line_bg} - } -} - -gls.right[2] = { - GitBranch = { - provider = "GitBranch", - condition = require("galaxyline.provider_vcs").check_git_workspace, - highlight = {colors.green, colors.line_bg} - } -} - -gls.right[3] = { - right_LeftRounded = { - provider = function() - return "" - end, - separator = " ", - separator_highlight = {colors.bg, colors.bg}, - highlight = {colors.red, colors.bg} - } -} - -gls.right[4] = { - SiMode = { - provider = function() - local alias = { - n = "NORMAL", - i = "INSERT", - c = "COMMAND", - V = "VISUAL", - [""] = "VISUAL", - v = "VISUAL", - R = "REPLACE" - } - return alias[vim.fn.mode()] - end, - highlight = {colors.bg, colors.red} - } -} - -gls.right[5] = { - PerCent = { - provider = "LinePercent", - separator = " ", - separator_highlight = {colors.red, colors.red}, - highlight = {colors.bg, colors.fg} - } -} - -gls.right[6] = { - rightRounded = { - provider = function() - return "" - end, - highlight = {colors.fg, colors.bg} - } -} diff --git a/nvim/lua/telescope-nvim/lua.lua b/nvim/lua/telescope-nvim/lua.lua deleted file mode 100644 index 5442b5b..0000000 --- a/nvim/lua/telescope-nvim/lua.lua +++ /dev/null @@ -1,77 +0,0 @@ -require("telescope").setup { - defaults = { - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case" - }, - prompt_position = "bottom", - prompt_prefix = "> ", - selection_caret = "> ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "descending", - layout_strategy = "horizontal", - layout_defaults = { - horizontal = { - mirror = false, - preview_width = 0.5 - }, - vertical = { - mirror = false - } - }, - file_sorter = require "telescope.sorters".get_fuzzy_file, - file_ignore_patterns = {}, - generic_sorter = require "telescope.sorters".get_generic_fuzzy_sorter, - shorten_path = true, - winblend = 0, - width = 0.75, - preview_cutoff = 120, - results_height = 1, - results_width = 0.8, - border = {}, - borderchars = {"─", "│", "─", "│", "╭", "╮", "╯", "╰"}, - color_devicons = true, - use_less = true, - set_env = {["COLORTERM"] = "truecolor"}, -- default = nil, - file_previewer = require "telescope.previewers".vim_buffer_cat.new, - grep_previewer = require "telescope.previewers".vim_buffer_vimgrep.new, - qflist_previewer = require "telescope.previewers".vim_buffer_qflist.new, - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require "telescope.previewers".buffer_previewer_maker - }, - extensions = { - media_files = { - filetypes = {"png", "webp", "jpg", "jpeg"}, - find_cmd = "rg" -- find command (defaults to `fd`) - } - } -} - -require("telescope").load_extension("media_files") - -local opt = {noremap = true, silent = true} - -vim.g.mapleader = " " - --- mappings ---vim.api.nvim_set_keymap("n", "ff", [[lua require('telescope.builtin').find_files()]], opt) -vim.api.nvim_set_keymap("n", "", [[lua require('telescope.builtin').find_files()]], opt) -vim.api.nvim_set_keymap( - "n", - "sp", - [[lua require('telescope').extensions.media_files.media_files()]], - opt -) -vim.api.nvim_set_keymap("n", "sb", [[lua require('telescope.builtin').buffers()]], opt) -vim.api.nvim_set_keymap("n", "sh", [[lua require('telescope.builtin').help_tags()]], opt) -vim.api.nvim_set_keymap("n", "so", [[lua require('telescope.builtin').oldfiles()]], opt) -vim.api.nvim_set_keymap("n", "sm", [[ Neoformat]], opt) - -vim.api.nvim_set_keymap("n", "", [[ %y+]], opt) diff --git a/nvim/lua/treesitter/lua.lua b/nvim/lua/treesitter/lua.lua deleted file mode 100644 index 37f2c7e..0000000 --- a/nvim/lua/treesitter/lua.lua +++ /dev/null @@ -1,18 +0,0 @@ -local ts_config = require("nvim-treesitter.configs") - -ts_config.setup { - ensure_installed = { - "javascript", - "html", - "css", - "bash", - "cpp", - "rust", - "lua", - "go", - }, - highlight = { - enable = true, - use_languagetree = true - } -} diff --git a/nvim/lua/utils/init.lua b/nvim/lua/utils/init.lua new file mode 100644 index 0000000..3f56f4d --- /dev/null +++ b/nvim/lua/utils/init.lua @@ -0,0 +1,198 @@ +local lv_utils = {} + + +-- copy current filepath to clipboard +function lv_utils.yank_filepath() + local p = vim.fn.expand('%:p') + print(p) + vim.fn.setreg('+',p) +end + +function lv_utils.define_augroups(definitions) -- {{{1 + -- Create autocommand groups based on the passed definitions + -- + -- The key will be the name of the group, and each definition + -- within the group should have: + -- 1. Trigger + -- 2. Pattern + -- 3. Text + -- just like how they would normally be defined from Vim itself + for group_name, definition in pairs(definitions) do + vim.cmd('augroup ' .. group_name) + vim.cmd('autocmd!') + + for _, def in pairs(definition) do + local command = table.concat(vim.tbl_flatten {'autocmd', def}, ' ') + vim.cmd(command) + end + + vim.cmd('augroup END') + end +end + +-- lsp + +function lv_utils.add_to_workspace_folder() + vim.lsp.buf.add_workspace_folder() +end + +function lv_utils.clear_references() + vim.lsp.buf.clear_references() +end + +function lv_utils.code_action() + vim.lsp.buf.code_action() +end + +function lv_utils.declaration() + vim.lsp.buf.declaration() + vim.lsp.buf.clear_references() +end + +function lv_utils.definition() + vim.lsp.buf.definition() + vim.lsp.buf.clear_references() +end + +function lv_utils.document_highlight() + vim.lsp.buf.document_highlight() +end + +function lv_utils.document_symbol() + vim.lsp.buf.document_symbol() +end + +function lv_utils.formatting() + vim.lsp.buf.formatting() +end + +function lv_utils.formatting_sync() + vim.lsp.buf.formatting_sync() +end + +function lv_utils.hover() + vim.lsp.buf.hover() +end + +function lv_utils.implementation() + vim.lsp.buf.implementation() +end + +function lv_utils.incoming_calls() + vim.lsp.buf.incoming_calls() +end + +function lv_utils.list_workspace_folders() + vim.lsp.buf.list_workspace_folders() +end + +function lv_utils.outgoing_calls() + vim.lsp.buf.outgoing_calls() +end + +function lv_utils.range_code_action() + vim.lsp.buf.range_code_action() +end + +function lv_utils.range_formatting() + vim.lsp.buf.range_formatting() +end + +function lv_utils.references() + vim.lsp.buf.references() + vim.lsp.buf.clear_references() +end + +function lv_utils.remove_workspace_folder() + vim.lsp.buf.remove_workspace_folder() +end + +function lv_utils.rename() + vim.lsp.buf.rename() +end + +function lv_utils.signature_help() + vim.lsp.buf.signature_help() +end + +function lv_utils.type_definition() + vim.lsp.buf.type_definition() +end + +function lv_utils.workspace_symbol() + vim.lsp.buf.workspace_symbol() +end + +-- diagnostic + +function lv_utils.get_all() + vim.lsp.diagnostic.get_all() +end + +function lv_utils.get_next() + vim.lsp.diagnostic.get_next() +end + +function lv_utils.get_prev() + vim.lsp.diagnostic.get_prev() +end + +function lv_utils.goto_next() + vim.lsp.diagnostic.goto_next() +end + +function lv_utils.goto_prev() + vim.lsp.diagnostic.goto_prev() +end + +function lv_utils.show_line_diagnostics() + vim.lsp.diagnostic.show_line_diagnostics() +end + +-- git signs + +function lv_utils.next_hunk() + require('gitsigns').next_hunk() +end + +function lv_utils.prev_hunk() + require('gitsigns').prev_hunk() +end + +function lv_utils.stage_hunk() + require('gitsigns').stage_hunk() +end + +function lv_utils.undo_stage_hunk() + require('gitsigns').undo_stage_hunk() +end + +function lv_utils.reset_hunk() + require('gitsigns').reset_hunk() +end + +function lv_utils.reset_buffer() + require('gitsigns').reset_buffer() +end + +function lv_utils.preview_hunk() + require('gitsigns').preview_hunk() +end + +function lv_utils.blame_line() + require('gitsigns').blame_line() +end + +-- misc +function lv_utils.file_exists(name) + local f = io.open(name, "r") + if f ~= nil then + io.close(f) + return true + else + return false + end +end + +return lv_utils + diff --git a/nvim/lua/utils/lua.lua b/nvim/lua/utils/lua.lua deleted file mode 100644 index c442dee..0000000 --- a/nvim/lua/utils/lua.lua +++ /dev/null @@ -1,47 +0,0 @@ -local scopes = {o = vim.o, b = vim.bo, w = vim.wo} - -local function opt(scope, key, value) - scopes[scope][key] = value - if scope ~= "o" then - scopes["o"][key] = value - end -end - -opt("o", "hidden", true) -opt("o", "ignorecase", true) -opt("o", "splitbelow", true) -opt("o", "splitright", true) -opt("o", "termguicolors", true) -opt("w", "number", true) -opt("o", "numberwidth", 2) - -opt("o", "mouse", "a") - -opt("w", "signcolumn", "yes") -opt("o", "cmdheight", 1) - -opt("o", "updatetime", 250) -- update interval for gitsigns -opt("o", "clipboard", "unnamedplus") - --- for indenline -local indent = 4 -opt("b", "expandtab", true ) -opt("b", "shiftwidth", indent ) -opt('b', 'tabstop', indent) -- Number of spaces tabs count for -opt('o', 'completeopt', 'menuone,noinsert,noselect') -- Completion options (for deoplete) - - - -local M = {} - -function M.is_buffer_empty() - -- Check whether the current buffer is empty - return vim.fn.empty(vim.fn.expand("%:t")) == 1 -end - -function M.has_width_gt(cols) - -- Check if the windows width is greater than a given number of columns - return vim.fn.winwidth(0) / 2 > cols -end - -return M diff --git a/nvim/lua/web-devicons/lua.lua b/nvim/lua/web-devicons/lua.lua deleted file mode 100644 index 5071e2e..0000000 --- a/nvim/lua/web-devicons/lua.lua +++ /dev/null @@ -1,71 +0,0 @@ -vim.cmd [[packadd nvim-web-devicons]] - -require "nvim-web-devicons".setup { - override = { - html = { - icon = "", - color = "#DE8C92", - name = "html" - }, - css = { - icon = "", - color = "#61afef", - name = "css" - }, - js = { - icon = "", - color = "#EBCB8B", - name = "js" - }, - png = { - icon = " ", - color = "#BD77DC", - name = "png" - }, - jpg = { - icon = " ", - color = "#BD77DC", - name = "jpg" - }, - jpeg = { - icon = " ", - color = "#BD77DC", - name = "jpeg" - }, - mp3 = { - icon = "", - color = "#C8CCD4", - name = "mp3" - }, - mp4 = { - icon = "", - color = "#C8CCD4", - name = "mp4" - }, - out = { - icon = "", - color = "#C8CCD4", - name = "out" - }, - toml = { - icon = "", - color = "#61afef", - name = "toml" - }, - lock = { - icon = "", - color = "#DE6B74", - name = "lock" - }, - zip = { - icon = "", - color = "#EBCB8B", - name = "zip" - }, - xz = { - icon = "", - color = "#EBCB8B", - name = "xz" - } - } -} diff --git a/nvim/settings.lua b/nvim/settings.lua new file mode 100644 index 0000000..78bd154 --- /dev/null +++ b/nvim/settings.lua @@ -0,0 +1,66 @@ +--[[ +O is the global options object + +Formatters and linters should be +filled in as strings with either +a global executable or a path to +an executable +]] + +-- general +O.auto_complete = true +O.colorscheme = 'lunar' +O.auto_close_tree = 0 +O.wrap_lines = false +O.timeoutlen = 100 +O.document_highlight = true +O.extras = true + +-- dashboard +-- O.dashboard.custom_header = {""} +-- O.dashboard.footer = {""} + + + +O.clang.diagnostics.virtual_text = false +O.clang.diagnostics.signs = false +O.clang.diagnostics.underline = false + +-- python +-- add things like O.python.formatter.yapf.exec_path +-- add things like O.python.linter.flake8.exec_path +-- add things like O.python.formatter.isort.exec_path +O.python.formatter = 'yapf' +-- O.python.linter = 'flake8' +O.python.isort = true +O.python.autoformat = true +O.python.diagnostics.virtual_text = true +O.python.diagnostics.signs = true +O.python.diagnostics.underline = true +O.python.analysis.type_checking = "off" +O.python.analysis.auto_search_paths = true +O.python.analysis.use_library_code_types = true + +-- lua +-- TODO look into stylua +O.lua.formatter = 'lua-format' +-- O.lua.formatter = 'lua-format' +--O.lua.autoformat = false + +-- javascript +O.tsserver.formatter = 'prettier' +O.tsserver.linter = nil +O.tsserver.autoformat = true + +-- json +O.json.autoformat = true + +-- ruby +O.ruby.autoformat = true + +-- go +O.go.autoformat = true +-- create custom autocommand field (This would be easy with lua) + +-- Turn off relative_numbers +-- O.relative_number = false diff --git a/nvim/utils/bin/install-latest-neovim b/nvim/utils/bin/install-latest-neovim new file mode 100755 index 0000000..8943b75 --- /dev/null +++ b/nvim/utils/bin/install-latest-neovim @@ -0,0 +1,9 @@ +!#/bin/bash +cd ~ +sudo rm -r neovim +git clone https://github.com/neovim/neovim +cd neovim +sudo make CMAKE_BUILD_TYPE=Release install +cd ~ +sudo rm -r neovim + diff --git a/nvim/utils/bin/java-linux-ls b/nvim/utils/bin/java-linux-ls new file mode 100755 index 0000000..c5ea391 --- /dev/null +++ b/nvim/utils/bin/java-linux-ls @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# NOTE: +# This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead +# +# NOTE: +# If you're not using Linux you'll need to adjust the `-configuration` option +# to point to the `config_mac' or `config_win` folders depending on your system. + +JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar" +GRADLE_HOME=$HOME/gradle $HOME/.sdkman/candidates/java/current/bin/java \ + -Declipse.application=org.eclipse.jdt.ls.core.id1 \ + -Dosgi.bundles.defaultStartLevel=4 \ + -Declipse.product=org.eclipse.jdt.ls.core.product \ + -Dlog.protocol=true \ + -Dlog.level=ALL \ + -javaagent:/usr/local/share/lombok/lombok.jar \ + -Xms1g \ + -Xmx2G \ + -jar $(echo "$JAR") \ + -configuration "$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/config_linux" \ + -data "${1:-$HOME/workspace}" \ + --add-modules=ALL-SYSTEM \ + --add-opens java.base/java.util=ALL-UNNAMED \ + --add-opens java.base/java.lang=ALL-UNNAMED + + # for older java versions if you wanna use lombok + # -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \ diff --git a/nvim/utils/bin/java-mac-ls b/nvim/utils/bin/java-mac-ls new file mode 100755 index 0000000..b7ad170 --- /dev/null +++ b/nvim/utils/bin/java-mac-ls @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# NOTE: +# This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead +# +# NOTE: +# If you're not using Linux you'll need to adjust the `-configuration` option +# to point to the `config_mac' or `config_win` folders depending on your system. + +JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar" +GRADLE_HOME=$HOME/gradle $HOME/.sdkman/candidates/java/current/bin/java \ + -Declipse.application=org.eclipse.jdt.ls.core.id1 \ + -Dosgi.bundles.defaultStartLevel=4 \ + -Declipse.product=org.eclipse.jdt.ls.core.product \ + -Dlog.protocol=true \ + -Dlog.level=ALL \ + -javaagent:/usr/local/share/lombok/lombok.jar \ + -Xms1g \ + -Xmx2G \ + -jar $(echo "$JAR") \ + -configuration "$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/config_mac" \ + -data "${1:-$HOME/workspace}" \ + --add-modules=ALL-SYSTEM \ + --add-opens java.base/java.util=ALL-UNNAMED \ + --add-opens java.base/java.lang=ALL-UNNAMED + + # for older java versions if you wanna use lombok + # -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \ + diff --git a/nvim/utils/bin/nv b/nvim/utils/bin/nv new file mode 100755 index 0000000..3408e21 --- /dev/null +++ b/nvim/utils/bin/nv @@ -0,0 +1,2 @@ +#!/bin/bash +nvim -u ~/.config/nvcode/init.lua diff --git a/nvim/utils/installer/install.sh b/nvim/utils/installer/install.sh new file mode 100755 index 0000000..10373fc --- /dev/null +++ b/nvim/utils/installer/install.sh @@ -0,0 +1,207 @@ +#!/bin/sh + +set -o nounset # error when referencing undefined variable +set -o errexit # exit when command fails + +installnodemac() { + brew install lua + brew install node + brew install yarn +} + +installnodeubuntu() { + sudo apt install nodejs + sudo apt install npm +} + +moveoldnvim() { + echo "Not installing LunarVim" + echo "Please move your ~/.config/nvim folder before installing" + exit +} + +installnodearch() { + sudo pacman -S nodejs + sudo pacman -S npm +} + +installnodefedora() { + sudo dnf install -y nodejs + sudo dnf install -y npm +} + +installnodegentoo() { + echo "Printing current node status..." + emerge -pqv net-libs/nodejs + echo "Make sure the npm USE flag is enabled for net-libs/nodejs" + echo "If it isn't enabled, would you like to enable it with flaggie? (Y/N)" + read answer + [ "$answer" != "${answer#[Yy]}" ] && sudo flaggie net-libs/nodejs +npm + sudo emerge -avnN net-libs/nodejs +} + +installnode() { + echo "Installing node..." + [ "$(uname)" == "Darwin" ] && installnodemac + [ -n "$(cat /etc/os-release | grep Ubuntu)" ] && installnodeubuntu + [ -f "/etc/arch-release" ] && installnodearch + [ -f "/etc/artix-release" ] && installnodearch + [ -f "/etc/fedora-release" ] && installnodefedora + [ -f "/etc/gentoo-release" ] && installnodegentoo + [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported" + sudo npm i -g neovim +} + +installpiponmac() { + sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python3 get-pip.py + rm get-pip.py +} + +installpiponubuntu() { + sudo apt install python3-pip >/dev/null +} + +installpiponarch() { + sudo pacman -S python-pip +} + +installpiponfedora() { + sudo dnf install -y pip >/dev/nul +} + +installpipongentoo() { + sudo emerge -avn dev-python/pip +} + +installpip() { + echo "Installing pip..." + [ "$(uname)" == "Darwin" ] && installpiponmac + [ -n "$(cat /etc/os-release | grep Ubuntu)" ] && installpiponubuntu + [ -f "/etc/arch-release" ] && installpiponarch + [ -f "/etc/fedora-release" ] && installpiponfedora + [ -f "/etc/gentoo-release" ] && installpipongentoo + [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported" +} + +installpynvim() { + echo "Installing pynvim..." + if [ -f "/etc/gentoo-release" ]; then + echo "Installing using Portage" + sudo emerge -avn dev-python/pynvim + else + pip3 install pynvim --user + fi +} + +installpacker() { + git clone https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim +} + +cloneconfig() { + echo "Cloning LunarVim configuration" + git clone https://github.com/ChristianChiarulli/lunarvim.git ~/.config/nvim + # mv $HOME/.config/nvim/init.lua $HOME/.config/nvim/init.lua.tmp + # mv $HOME/.config/nvim/utils/init.lua $HOME/.config/nvim/init.lua + nvim -u $HOME/.config/nvim/init.lua +PackerInstall + # rm $HOME/.config/nvim/init.lua + # mv $HOME/.config/nvim/init.lua.tmp $HOME/.config/nvim/init.lua +} + +asktoinstallnode() { + echo "node not found" + echo -n "Would you like to install node now (y/n)? " + read answer + [ "$answer" != "${answer#[Yy]}" ] && installnode +} + +asktoinstallpip() { + # echo "pip not found" + # echo -n "Would you like to install pip now (y/n)? " + # read answer + # [ "$answer" != "${answer#[Yy]}" ] && installpip + echo "Please install pip3 before continuing with install" + exit +} + +installonmac() { + brew install ripgrep fzf ranger + npm install -g tree-sitter-cli +} + +pipinstallueberzug() { + which pip3 >/dev/null && pip3 install ueberzug || echo "Not installing ueberzug pip not found" +} + +installonubuntu() { + sudo apt install ripgrep fzf ranger + sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev + pip3 install ueberzug + pip3 install neovim-remote + npm install -g tree-sitter-cli +} + +installonarch() { + sudo pacman -S ripgrep fzf ranger + which yay >/dev/null && yay -S python-ueberzug-git || pipinstallueberzug + pip3 install neovim-remote + npm install -g tree-sitter-cli +} + +installonfedora() { + sudo dnf groupinstall "X Software Development" + sudo dnf install -y fzf ripgrep ranger + pip3 install wheel ueberzug +} + +installongentoo() { + sudo emerge -avn sys-apps/ripgrep app-shells/fzf app-misc/ranger dev-python/neovim-remote virtual/jpeg sys-libs/zlib + pipinstallueberzug + npm install -g tree-sitter-cli +} + +installextrapackages() { + [ "$(uname)" == "Darwin" ] && installonmac + [ -n "$(cat /etc/os-release | grep Ubuntu)" ] && installonubuntu + [ -f "/etc/arch-release" ] && installonarch + [ -f "/etc/artix-release" ] && installonarch + [ -f "/etc/fedora-release" ] && installonfedora + [ -f "/etc/gentoo-release" ] && installongentoo + [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported" +} + +# Welcome +echo 'Installing LunarVim' + +# move old nvim directory if it exists +[ -d "$HOME/.config/nvim" ] && moveoldnvim + +# install pip +which pip3 >/dev/null && echo "pip installed, moving on..." || asktoinstallpip + +# install node and neovim support +which node >/dev/null && echo "node installed, moving on..." || asktoinstallnode + +# install pynvim +pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on..." || installpynvim + +if [ -e "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" ]; then + echo 'packer already installed' +else + installpacker +fi + +if [ -e "$HOME/.config/nvim/init.lua" ]; then + echo 'nvcode already installed' +else + # clone config down + cloneconfig + # echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc + # echo 'export PATH=$HOME/.config/nvcode/utils/bin:$PATH' >>~/.bashrc +fi + +echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts" + +# echo "I also recommend you add 'set preview_images_method ueberzug' to ~/.config/ranger/rc.conf" + +# echo 'export PATH=/home/$USER/.config/nvcode/utils/bin:$PATH appending to zshrc/bashrc' diff --git a/nvim/utils/media/demo.png b/nvim/utils/media/demo.png new file mode 100755 index 0000000..08e3dba Binary files /dev/null and b/nvim/utils/media/demo.png differ diff --git a/nvim/utils/vscode_config/keybindings.json b/nvim/utils/vscode_config/keybindings.json new file mode 100644 index 0000000..49e0f45 --- /dev/null +++ b/nvim/utils/vscode_config/keybindings.json @@ -0,0 +1,171 @@ +[ + { + "key": "shift+ctrl+e", + "command": "actions.findWithSelection" + }, + { + "key": "ctrl+e", + "command": "-actions.findWithSelection" + }, + { + "key": "ctrl+e", + "command": "workbench.view.explorer" + }, + { + "key": "shift+ctrl+e", + "command": "-workbench.view.explorer" + }, + { + "key": "r", + "command": "renameFile", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "enter", + "command": "-renameFile", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "j", + "command": "list.focusDown", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "k", + "command": "list.focusUp", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "ctrl+j", + "command": "selectNextSuggestion", + "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible" + }, + { + "key": "ctrl+k", + "command": "selectPrevSuggestion", + "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible" + }, + { + "key": "ctrl+j", + "command": "workbench.action.quickOpenNavigateNext", + "when": "inQuickOpen" + }, + { + "key": "tab", + "command": "selectNextSuggestion", + "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible" + }, + { + "key": "tab", + "command": "workbench.action.quickOpenNavigateNext", + "when": "inQuickOpen" + }, + { + "key": "shift+tab", + "command": "selectPrevSuggestion", + "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible" + }, + { + "key": "shift+tab", + "command": "workbench.action.quickOpenNavigatePrevious", + "when": "inQuickOpen" + }, + { + "key": "ctrl+k", + "command": "workbench.action.quickOpenNavigatePrevious", + "when": "inQuickOpen" + }, + { + "key": "enter", + "command": "list.select", + "when": "explorerViewletVisible && filesExplorerFocus" + }, + { + "key": "l", + "command": "list.select", + "when": "explorerViewletVisible && filesExplorerFocus && !inputFocus" + }, + { + "key": "o", + "command": "list.toggleExpand", + "when": "explorerViewletVisible && filesExplorerFocus && !inputFocus" + }, + { + "key": "h", + "command": "list.collapse", + "when": "explorerViewletVisible && filesExplorerFocus && !inputFocus" + }, + { + "key": "a", + "command": "explorer.newFile", + "when": "filesExplorerFocus && !inputFocus" + }, + { + "key": "shift+a", + "command": "explorer.newFolder", + "when": "filesExplorerFocus && !inputFocus" + }, + { + "key": "shift+;", + "command": "insertPrevSuggestion", + "when": "hasOtherSuggestions && textInputFocus && textInputFocus && !inSnippetMode && !suggestWidgetVisible && config.editor.tabCompletion == 'on'" + }, + { + "key": "ctrl+l", + "when": "sideBarFocus", + "command": "workbench.action.focusActiveEditorGroup" + }, + { + "key": "ctrl+k", + "command": "workbench.action.focusActiveEditorGroup", + "when": "terminalFocus" + }, + { + "key": "ctrl+shift+t", + "command": "workbench.action.terminal.focus", + "when": "!terminalFocus" + }, + { + "key": "ctrl+j", + "command": "-editor.action.insertLineAfter", + "when": "editorTextFocus && neovim.ctrlKeysInsert && !neovim.recording && neovim.mode == 'insert'" + }, + { + "key": "alt+j", + "command": "workbench.action.terminal.focus", + "when": "!terminalFocus" + }, + { + "key": "ctrl+shift+t", + "command": "workbench.action.togglePanel" + }, + { + "key": "ctrl+j", + "command": "-workbench.action.togglePanel" + }, + { + "key": "shift+k", + "command": "editor.action.showHover", + "when": "editorTextFocus && neovim.mode != 'insert'" + }, + { + "key": "ctrl+k ctrl+i", + "command": "-editor.action.showHover", + "when": "editorTextFocus" + }, + { + "key": "shift+tab", + "command": "-acceptAlternativeSelectedSuggestion", + "when": "suggestWidgetVisible && textInputFocus && textInputFocus" + }, + { + "key": "ctrl+f", + "command": "-vscode-neovim.ctrl-f", + "when": "editorTextFocus && neovim.ctrlKeysNormal && neovim.init && neovim.mode != 'insert'" + }, + { + "key": "space", + "command": "whichkey.show", + "when": "neovim.mode != 'insert'" + } +] diff --git a/nvim/utils/vscode_config/settings.json b/nvim/utils/vscode_config/settings.json new file mode 100644 index 0000000..5ba2f46 --- /dev/null +++ b/nvim/utils/vscode_config/settings.json @@ -0,0 +1,1128 @@ +{ + "vscode-neovim.neovimExecutablePaths.darwin": "/usr/local/bin/nvim", + "vscode-neovim.neovimExecutablePaths.linux": "/usr/local/bin/nvim", + "vscode-neovim.neovimInitVimPaths.darwin": "$HOME/.config/nvim/vimscript/nv-vscode/init.vim", + "vscode-neovim.neovimInitVimPaths.linux": "$HOME/.config/nvim/vimscript/nv-vscode/init.vim", + "whichkey.sortOrder": "alphabetically", + "whichkey.delay": 0, + "whichkey.bindings": [ + { + "key": ";", + "name": "commands", + "type": "command", + "command": "workbench.action.showCommands" + }, + { + "key": "/", + "name": "comment", + "type": "command", + "command": "vscode-neovim.send", + "args": "" + }, + { + "key": "?", + "name": "View All References", + "type": "command", + "command": "references-view.find", + "when": "editorHasReferenceProvider" + }, + { + "key": "b", + "name": "Buffers/Editors...", + "type": "bindings", + "bindings": [ + { + "key": "b", + "name": "Show all buffers/editors", + "type": "command", + "command": "workbench.action.showAllEditors" + }, + { + "key": "d", + "name": "Close active editor", + "type": "command", + "command": "workbench.action.closeActiveEditor" + }, + { + "key": "h", + "name": "Move editor into left group", + "type": "command", + "command": "workbench.action.moveEditorToLeftGroup" + }, + { + "key": "j", + "name": "Move editor into below group", + "type": "command", + "command": "workbench.action.moveEditorToBelowGroup" + }, + { + "key": "k", + "name": "Move editor into above group", + "type": "command", + "command": "workbench.action.moveEditorToAboveGroup" + }, + { + "key": "l", + "name": "Move editor into right group", + "type": "command", + "command": "workbench.action.moveEditorToRightGroup" + }, + { + "key": "m", + "name": "Close other editors", + "type": "command", + "command": "workbench.action.closeOtherEditors" + }, + { + "key": "n", + "name": "Next editor", + "type": "command", + "command": "workbench.action.nextEditor" + }, + { + "key": "p", + "name": "Previous editor", + "type": "command", + "command": "workbench.action.previousEditor" + }, + { + "key": "N", + "name": "New untitled editor", + "type": "command", + "command": "workbench.action.files.newUntitledFile" + }, + { + "key": "u", + "name": "Reopen closed editor", + "type": "command", + "command": "workbench.action.reopenClosedEditor" + }, + { + "key": "y", + "name": "Copy buffer to clipboard", + "type": "commands", + "commands": [ + "editor.action.selectAll", + "editor.action.clipboardCopyAction", + "cancelSelection" + ] + } + ] + }, + { + "key": "d", + "name": "Debug...", + "type": "bindings", + "bindings": [ + { + "key": "d", + "name": "Start debug", + "type": "command", + "command": "workbench.action.debug.start" + }, + { + "key": "S", + "name": "Stop debug", + "type": "command", + "command": "workbench.action.debug.stop" + }, + { + "key": "c", + "name": "Continue debug", + "type": "command", + "command": "workbench.action.debug.continue" + }, + { + "key": "p", + "name": "Pause debug", + "type": "command", + "command": "workbench.action.debug.pause" + }, + { + "key": "r", + "name": "Run without debugging", + "type": "command", + "command": "workbench.action.debug.run" + }, + { + "key": "R", + "name": "Restart ebug", + "type": "command", + "command": "workbench.action.debug.restart" + }, + { + "key": "i", + "name": "Step into", + "type": "command", + "command": "workbench.action.debug.stepInto" + }, + { + "key": "s", + "name": "Step over", + "type": "command", + "command": "workbench.action.debug.stepOver" + }, + { + "key": "o", + "name": "Step out", + "type": "command", + "command": "workbench.action.debug.stepOut" + }, + { + "key": "b", + "name": "Toggle breakpoint", + "type": "command", + "command": "editor.debug.action.toggleBreakpoint" + }, + { + "key": "B", + "name": "Toggle inline breakpoint", + "type": "command", + "command": "editor.debug.action.toggleInlineBreakpoint" + }, + { + "key": "j", + "name": "Jump to cursor", + "type": "command", + "command": "debug.jumpToCursor" + }, + { + "key": "v", + "name": "REPL", + "type": "command", + "command": "workbench.debug.action.toggleRepl" + }, + { + "key": "w", + "name": "Focus on watch window", + "type": "command", + "command": "workbench.debug.action.focusWatchView" + }, + { + "key": "W", + "name": "Add to watch", + "type": "command", + "command": "editor.debug.action.selectionToWatch" + } + ] + }, + { + "key": "e", + "name": "Toggle Explorer", + "type": "command", + "command": "workbench.action.toggleSidebarVisibility" + }, + { + "key": "f", + "name": "Find & Replace...", + "type": "bindings", + "bindings": [ + { + "key": "f", + "name": "File", + "type": "command", + "command": "editor.action.startFindReplaceAction" + }, + { + "key": "s", + "name": "Symbol", + "type": "command", + "command": "editor.action.rename", + "when": "editorHasRenameProvider && editorTextFocus && !editorReadonly" + }, + { + "key": "p", + "name": "Project", + "type": "command", + "command": "workbench.action.replaceInFiles" + } + ] + }, + { + "key": "g", + "name": "Git...", + "type": "bindings", + "bindings": [ + { + "key": "/", + "name": "Search Commits", + "command": "gitlens.showCommitSearch", + "type": "command", + "when": "gitlens:enabled && config.gitlens.keymap == 'alternate'" + }, + { + "key": "a", + "name": "Stage", + "type": "command", + "command": "git.stage" + }, + { + "key": "b", + "name": "Checkout", + "type": "command", + "command": "git.checkout" + }, + { + "key": "B", + "name": "Browse", + "type": "command", + "command": "gitlens.openFileInRemote" + }, + { + "key": "c", + "name": "Commit", + "type": "command", + "command": "git.commit" + }, + { + "key": "C", + "name": "Cherry Pick", + "type": "command", + "command": "gitlens.views.cherryPick" + }, + { + "key": "d", + "name": "Delete Branch", + "type": "command", + "command": "git.deleteBranch" + }, + { + "key": "f", + "name": "Fetch", + "type": "command", + "command": "git.fetch" + }, + { + "key": "F", + "name": "Pull From", + "type": "command", + "command": "git.pullFrom" + }, + { + "key": "g", + "name": "Graph", + "type": "command", + "command": "git-graph.view" + }, + { + "key": "h", + "name": "Heatmap", + "type": "command", + "command": "gitlens.toggleFileHeatmap" + }, + { + "key": "H", + "name": "History", + "type": "command", + "command": "git.viewFileHistory" + }, + { + "key": "i", + "name": "Init", + "type": "command", + "command": "git.init" + }, + { + "key": "j", + "name": "Next Change", + "type": "command", + "command": "workbench.action.editor.nextChange" + }, + { + "key": "k", + "name": "Previous Change", + "type": "command", + "command": "workbench.action.editor.previousChange" + }, + { + "key": "l", + "name": "Toggle Line Blame", + "type": "command", + "command": "gitlens.toggleLineBlame", + "when": "editorTextFocus && gitlens:canToggleCodeLens && gitlens:enabled && config.gitlens.keymap == 'alternate'" + }, + { + "key": "L", + "name": "Toggle GitLens", + "type": "command", + "command": "gitlens.toggleCodeLens", + "when": "editorTextFocus && gitlens:canToggleCodeLens && gitlens:enabled && config.gitlens.keymap == 'alternate'" + }, + { + "key": "m", + "name": "Merge", + "type": "command", + "command": "git.merge" + }, + { + "key": "p", + "name": "Push", + "type": "command", + "command": "git.push" + }, + { + "key": "P", + "name": "Push", + "type": "command", + "command": "git.pull" + }, + { + "key": "s", + "name": "Stash", + "type": "command", + "command": "workbench.view.scm" + }, + { + "key": "S", + "name": "Status", + "type": "command", + "command": "gitlens.showQuickRepoStatus", + "when": "gitlens:enabled && config.gitlens.keymap == 'alternate'" + }, + { + "key": "t", + "name": "Create Tag", + "type": "command", + "command": "git.createTag" + }, + { + "key": "T", + "name": "Delete Tag", + "type": "command", + "command": "git.deleteTag" + }, + { + "key": "U", + "name": "Unstage", + "type": "command", + "command": "git.unstage" + } + ] + }, + { + "key": "h", + "name": "Split Horizontal", + "type": "command", + "command": "workbench.action.splitEditorDown" + }, + { + "key": "i", + "name": "Insert...", + "type": "bindings", + "bindings": [ + { + "key": "j", + "name": "Insert line below", + "type": "command", + "command": "editor.action.insertLineAfter" + }, + { + "key": "k", + "name": "Insert line above", + "type": "command", + "command": "editor.action.insertLineBefore" + }, + { + "key": "s", + "name": "Insert snippet", + "type": "command", + "command": "editor.action.insertSnippet" + } + ] + }, + { + "key": "l", + "name": "LSP...", + "type": "bindings", + "bindings": [ + { + "key": ";", + "name": "Refactor", + "type": "command", + "command": "editor.action.refactor", + "when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly" + }, + { + "key": "a", + "name": "Auto Fix", + "type": "command", + "command": "editor.action.autoFix", + "when": "editorTextFocus && !editorReadonly && supportedCodeAction =~ /(\\s|^)quickfix\\b/" + }, + { + "key": "d", + "name": "Definition", + "type": "command", + "command": "editor.action.revealDefinition", + "when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor" + }, + { + "key": "D", + "name": "Declaration", + "type": "command", + "command": "editor.action.revealDeclaration" + }, + { + "key": "e", + "name": "Errors", + "type": "command", + "command": "workbench.actions.view.problems" + }, + { + "key": "f", + "name": "Format", + "type": "command", + "command": "editor.action.formatDocument", + "when": "editorHasDocumentFormattingProvider && editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor" + }, + { + "key": "i", + "name": "Implementation", + "type": "command", + "command": "editor.action.goToImplementation", + "when": "editorHasImplementationProvider && editorTextFocus && !isInEmbeddedEditor" + }, + { + "key": "l", + "name": "Code Lens", + "type": "command", + "command": "codelens.showLensesInCurrentLine" + }, + { + "key": "n", + "name": "Next Problem", + "type": "command", + "command": "editor.action.marker.next", + "when": "editorFocus" + }, + { + "key": "N", + "name": "Next Problem (Proj)", + "type": "command", + "command": "editor.action.marker.nextInFiles", + "when": "editorFocus" + }, + { + "key": "o", + "name": "Outline", + "type": "command", + "command": "outline.focus" + }, + { + "key": "p", + "name": "Prev Problem", + "type": "command", + "command": "editor.action.marker.prevInFiles", + "when": "editorFocus" + }, + { + "key": "P", + "name": "Prev Problem (Proj)", + "type": "command", + "command": "editor.action.marker.prev", + "when": "editorFocus" + }, + { + "key": "q", + "name": "Quick Fix", + "type": "command", + "command": "editor.action.quickFix", + "when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly" + }, + { + "key": "r", + "name": "References", + "type": "command", + "command": "editor.action.goToReferences", + "when": "editorHasReferenceProvider && editorTextFocus && !inReferenceSearchEditor && !isInEmbeddedEditor" + }, + { + "key": "R", + "name": "Rename", + "type": "command", + "command": "editor.action.rename", + "when": "editorHasRenameProvider && editorTextFocus && !editorReadonly" + }, + { + "key": "v", + "name": "View All References", + "type": "command", + "command": "references-view.find", + "when": "editorHasReferenceProvider" + }, + { + "key": "s", + "name": "Go To Symbol", + "type": "command", + "command": "workbench.action.gotoSymbol" + }, + { + "key": "S", + "name": "Show All Symbols", + "type": "command", + "command": "workbench.action.showAllSymbols" + } + ] + }, + { + "key": "m", + "name": "Mark...", + "type": "bindings", + "bindings": [ + { + "key": "c", + "name": "Clear Bookmarks", + "type": "command", + "command": "bookmarks.clear" + }, + { + "key": "j", + "name": "Next Bookmark", + "type": "command", + "command": "bookmarks.jumpToNext", + "when": "editorTextFocus" + }, + { + "key": "k", + "name": "Previous Bookmark", + "type": "command", + "command": "bookmarks.jumpToPrevious", + "when": "editorTextFocus" + }, + { + "key": "l", + "name": "List Bookmarks", + "type": "command", + "command": "bookmarks.listFromAllFiles", + "when": "editorTextFocus" + }, + { + "key": "r", + "name": "Refresh Bookmarks", + "type": "command", + "command": "bookmarks.refresh" + }, + { + "key": "t", + "name": "Toggle Bookmark", + "type": "command", + "command": "bookmarks.toggle", + "when": "editorTextFocus" + }, + { + "key": "s", + "name": "Show Bookmarks", + "type": "command", + "command": "workbench.view.extension.bookmarks" + } + ] + }, + { + "key": "M", + "name": "Minimap", + "type": "command", + "command": "editor.action.toggleMinimap" + }, + { + "key": "n", + "name": "No Highlight", + "type": "command", + "command": "vscode-neovim.send", + "args": ":noh" + }, + { + "key": "o", + "name": "Open...", + "type": "bindings", + "bindings": [ + { + "key": "d", + "name": "Directory", + "type": "command", + "command": "workbench.action.files.openFolder" + }, + { + "key": "r", + "name": "Recent", + "type": "command", + "command": "workbench.action.openRecent" + }, + { + "key": "f", + "name": "File", + "type": "command", + "command": "workbench.action.files.openFile" + } + ] + }, + { + "key": "p", + "name": "Peek...", + "type": "bindings", + "bindings": [ + { + "key": "d", + "name": "Definition", + "type": "command", + "command": "editor.action.peekDefinition", + "when": "editorHasDefinitionProvider && editorTextFocus && !inReferenceSearchEditor && !isInEmbeddedEditor" + }, + { + "key": "D", + "name": "Declaration", + "type": "command", + "command": "editor.action.peekDeclaration" + }, + { + "key": "i", + "name": "Implementation", + "type": "command", + "command": "editor.action.peekImplementation", + "when": "editorHasImplementationProvider && editorTextFocus && !inReferenceSearchEditor && !isInEmbeddedEditor" + }, + { + "key": "p", + "name": "Toggle Focus", + "type": "command", + "command": "togglePeekWidgetFocus", + "when": "inReferenceSearchEditor || referenceSearchVisible" + }, + { + "key": "r", + "name": "References", + "type": "command", + "command": "editor.action.referenceSearch.trigger" + }, + { + "key": "t", + "name": "Type Definition", + "type": "command", + "command": "editor.action.peekTypeDefinition" + } + ] + }, + { + "key": "s", + "name": "Search...", + "type": "bindings", + "bindings": [ + { + "key": "f", + "name": "Files", + "type": "command", + "command": "workbench.action.quickOpen" + }, + { + "key": "t", + "name": "Text", + "type": "command", + "command": "workbench.action.findInFiles" + } + ] + }, + { + "key": "S", + "name": "Show...", + "type": "bindings", + "bindings": [ + { + "key": "e", + "name": "Show explorer", + "type": "command", + "command": "workbench.view.explorer" + }, + { + "key": "s", + "name": "Show search", + "type": "command", + "command": "workbench.view.search" + }, + { + "key": "g", + "name": "Show source control", + "type": "command", + "command": "workbench.view.scm" + }, + { + "key": "t", + "name": "Show test", + "type": "command", + "command": "workbench.view.extension.test" + }, + { + "key": "r", + "name": "Show remote explorer", + "type": "command", + "command": "workbench.view.remote" + }, + { + "key": "x", + "name": "Show extensions", + "type": "command", + "command": "workbench.view.extensions" + }, + { + "key": "p", + "name": "Show problem", + "type": "command", + "command": "workbench.actions.view.problems" + }, + { + "key": "o", + "name": "Show output", + "type": "command", + "command": "workbench.action.output.toggleOutput" + }, + { + "key": "d", + "name": "Show debug console", + "type": "command", + "command": "workbench.debug.action.toggleRepl" + } + ] + }, + { + "key": "t", + "name": "Terminal...", + "type": "bindings", + "bindings": [ + { + "key": "t", + "name": "Toggle Terminal", + "type": "command", + "command": "workbench.action.togglePanel" + }, + { + "key": "T", + "name": "Focus Terminal", + "type": "command", + "command": "workbench.action.terminal.toggleTerminal", + "when": "!terminalFocus" + } + ] + }, + { + "key": "u", + "name": "UI toggles...", + "type": "bindings", + "bindings": [ + { + "key": "a", + "name": "Toggle tool/activity bar visibility", + "type": "command", + "command": "workbench.action.toggleActivityBarVisibility" + }, + { + "key": "b", + "name": "Toggle side bar visibility", + "type": "command", + "command": "workbench.action.toggleSidebarVisibility" + }, + { + "key": "j", + "name": "Toggle panel visibility", + "type": "command", + "command": "workbench.action.togglePanel" + }, + { + "key": "F", + "name": "Toggle full screen", + "type": "command", + "command": "workbench.action.toggleFullScreen" + }, + { + "key": "s", + "name": "Select theme", + "type": "command", + "command": "workbench.action.selectTheme" + }, + { + "key": "m", + "name": "Toggle maximized panel", + "type": "command", + "command": "workbench.action.toggleMaximizedPanel" + }, + { + "key": "T", + "name": "Toggle tab visibility", + "type": "command", + "command": "workbench.action.toggleTabsVisibility" + } + ] + }, + { + "key": "v", + "name": "Split Vertical", + "type": "command", + "command": "workbench.action.splitEditor" + }, + { + "key": "w", + "name": "Window...", + "type": "bindings", + "bindings": [ + { + "key": "W", + "name": "Focus previous editor group", + "type": "command", + "command": "workbench.action.focusPreviousGroup" + }, + { + "key": "h", + "name": "Move editor group left", + "type": "command", + "command": "workbench.action.moveActiveEditorGroupLeft" + }, + { + "key": "j", + "name": "Move editor group down", + "type": "command", + "command": "workbench.action.moveActiveEditorGroupDown" + }, + { + "key": "k", + "name": "Move editor group up", + "type": "command", + "command": "workbench.action.moveActiveEditorGroupUp" + }, + { + "key": "l", + "name": "Move editor group right", + "type": "command", + "command": "workbench.action.moveActiveEditorGroupRight" + }, + { + "key": "t", + "name": "Toggle editor group sizes", + "type": "command", + "command": "workbench.action.toggleEditorWidths" + }, + { + "key": "m", + "name": "Maximize editor group", + "type": "command", + "command": "workbench.action.minimizeOtherEditors" + }, + { + "key": "M", + "name": "Maximize editor group and hide side bar", + "type": "command", + "command": "workbench.action.maximizeEditor" + }, + { + "key": "=", + "name": "Reset editor group sizes", + "type": "command", + "command": "workbench.action.evenEditorWidths" + }, + { + "key": "z", + "name": "Combine all editors", + "type": "command", + "command": "workbench.action.joinAllGroups" + }, + { + "key": "d", + "name": "Close editor group", + "type": "command", + "command": "workbench.action.closeEditorsInGroup" + }, + { + "key": "x", + "name": "Close all editor groups", + "type": "command", + "command": "workbench.action.closeAllGroups" + } + ] + }, + { + "key": "x", + "name": "Extensions", + "type": "command", + "command": "workbench.view.extensions" + }, + { + "key": "y", + "name": "Sync...", + "type": "bindings", + "bindings": [ + { + "key": "d", + "name": "Download Settings", + "type": "command", + "command": "extension.downloadSettings" + }, + { + "key": "u", + "name": "Upload Settings", + "type": "command", + "command": "extension.updateSettings" + } + ] + }, + { + "key": "z", + "name": "Toggle zen mode", + "type": "command", + "command": "workbench.action.toggleZenMode" + } + ], + "workbench.editor.showTabs": true, + "sync.gist": "939951904a077b97f8001bc35f6b5948", + "gitlens.hovers.currentLine.over": "line", + "editor.suggestSelection": "first", + "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", + "python.pythonPath": "/home/chris/.miniconda/envs/ds/bin/python", + "java.semanticHighlighting.enabled": true, + "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m -javaagent:\"/home/chris/.vscode-oss/extensions/gabrielbb.vscode-lombok-1.0.1/server/lombok.jar\"", + "workbench.list.automaticKeyboardNavigation": false, + "oneDarkPro.editorTheme": "oneDarkPro", + "python.languageServer": "Pylance", + "editor.scrollbar.horizontal": "hidden", + "editor.scrollbar.vertical": "hidden", + "kite.showWelcomeNotificationOnStartup": false, + "python.terminal.activateEnvironment": false, + "editor.cursorBlinking": "solid", + "editor.fontFamily": "JetBrainsMono Nerd Font, Hack, Menlo, Monaco, 'Courier New', monospace", + "files.exclude": { + "**/.classpath": true, + "**/.project": true, + "**/.settings": true, + "**/.factorypath": true + }, + "terminal.external.osxExec": "iTerm.app", + "editor.minimap.enabled": false, + "workbench.activityBar.visible": true, + "leetcode.workspaceFolder": "/Users/chris/Repos/leetcode", + "leetcode.defaultLanguage": "javascript", + "leetcode.hint.configWebviewMarkdown": false, + "leetcode.hint.commentDescription": false, + "window.zoomLevel": 2, + "window.menuBarVisibility": "toggle", + "python.dataScience.alwaysTrustNotebooks": true, + "python.condaPath": "$HOME/.miniconda/bin/conda", + "python.formatting.provider": "black", + "python.insidersChannel": "off", + "terminal.integrated.shell.linux": "/bin/zsh", + "terminal.external.linuxExec": "/usr/bin/alacritty", + "code-runner.executorMap": { + "python": "$pythonPath $fileName", + "java": "cd $dir && javac $fileName && java $fileNameWithoutExt", + "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt" + }, + "editor.tokenColorCustomizations": { + "[One Dark Pro]": { + "textMateRules": [ + { + "scope": [ + "support.class.component.open.jsx", + "support.class.component.close.jsx", + "entity.name.function.js" + ], + "settings": { + "foreground": "#61afef" + } + }, + + { + "scope": [ + "variable.other.constant.object.js", + + "punctuation.section.embedded.begin.jsx", + "punctuation.section.embedded.end.jsx" + ], + "settings": { + "foreground": "#abb2bf" + } + }, + { + "scope": ["punctuation.definition.tag.jsx"], + "settings": { + "foreground": "#5c6370" + } + }, + { + "scope": [ + "variable.other.readwrite.js", + "variable.other.property.js", + "variable.parameter", + "variable.other.object.js" + ], + "settings": { + "foreground": "#56b6c2" + } + }, + { + "scope": ["entity.other.attribute-name.jsx"], + "settings": { + "foreground": "#e5c07b" + } + }, + { + "scope": [ + "keyword.operator.assignment.js", + "keyword.operator.assignment.jsx", + "string.unquoted.js", + "keyword.operator.typeof.js", + "meta.embedded.expression.js", + "constant.other.object.key.js", + "keyword.operator.logical.js" + ], + "settings": { + "foreground": "#c678dd" + } + }, + { + "scope": ["variable.other.constant.object.js"], + "settings": { + "foreground": "#e06c75" + } + } + ] + } + }, + + "workbench.colorCustomizations": { + "[Default Dark+]": { + "statusBar.background": "#2E2E2E", + "statusBar.foreground": "#8C8C8C", + "statusBarItem.remoteBackground": "#2E2E2E", + "statusBarItem.remoteForeground": "#8C8C8C", + "activityBar.background": "#2E2E2E", + "tab.inactiveBackground": "#2E2E2E" + }, + "[One Dark Pro]": { + "editor.background": "#1e2127", + "terminal.foreground": "#abb2bf", + "terminal.ansiBlack": "#1e2127", + "terminal.ansiBlue": "#61afef", + "terminal.ansiCyan": "#56b6c2", + "terminal.ansiGreen": "#98C379", + "terminal.ansiMagenta": "#c678dd", + "terminal.ansiRed": "#e06c75", + "terminal.ansiWhite": "#abb2bf", + "terminal.ansiYellow": "#d19a66", + "terminal.ansiBrightBlack": "#5c6370", + "terminal.ansiBrightBlue": "#61afef", + "terminal.ansiBrightCyan": "#56b6c2", + "terminal.ansiBrightGreen": "#98c379", + "terminal.ansiBrightMagenta": "#c678dd", + "terminal.ansiBrightRed": "#e06c75", + "terminal.ansiBrightWhite": "#ffffff", + "terminal.ansiBrightYellow": "#d19a66" + } + }, + "gitlens.advanced.telemetry.enabled": false, + "gitlens.currentLine.enabled": false, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "emmet.showSuggestionsAsSnippets": true, + "material-icon-theme.showWelcomeMessage": false, + "gitlens.codeLens.enabled": false, + "workbench.iconTheme": "material-icon-theme", + "git.autofetch": true, + "workbench.startupEditor": "newUntitledFile", + "python.showStartPage": false, + "editor.snippetSuggestions": "bottom" +} diff --git a/nvim/vimscript/functions.vim b/nvim/vimscript/functions.vim new file mode 100644 index 0000000..e4ad801 --- /dev/null +++ b/nvim/vimscript/functions.vim @@ -0,0 +1,73 @@ +command! LspCodeAction lua require 'lv-utils'.code_action() +command! LspDeclaration lua require 'lv-utils'.declaration() +command! LspDefinition lua require 'lv-utils'.definition() +command! LspDocumentSymbol lua require 'lv-utils'.document_symbol() +command! LspFormatting lua require 'lv-utils'.formatting() +command! LspFormattingSync lua require 'lv-utils'.formatting_sync() +command! LspHover lua require 'lv-utils'.hover() +command! LspImplementation lua require 'lv-utils'.implementation() +command! LspRangeCodeAction lua require 'lv-utils'.range_code_action() +command! LspRangeFormatting lua require 'lv-utils'.range_formatting() +command! LspReferences lua require 'lv-utils'.references() +command! LspRename lua require 'lv-utils'.rename() +command! LspTypeDefinition lua require 'lv-utils'.type_definition() +command! LspWorkspaceSymbol lua require 'lv-utils'.workspace_symbol() +command! LspGotoNext lua require 'lv-utils'.goto_next() +command! LspGotoPrev lua require 'lv-utils'.goto_prev() +command! LspShowLineDiagnostics lua require 'lv-utils'.show_line_diagnostics() +command! NextHunk lua require 'lv-utils'.next_hunk() +command! PrevHunk lua require 'lv-utils'.prev_hunk() +command! StageHunk lua require 'lv-utils'.stage_hunk() +command! UndoStageHunk lua require 'lv-utils'.undo_stage_hunk() +command! ResetHunk lua require 'lv-utils'.reset_hunk() +command! ResetBuffer lua require 'lv-utils'.reset_buffer() +command! PreviewHunk lua require 'lv-utils'.preview_hunk() +command! BlameLine lua require 'lv-utils'.blame_line() +command! W noa w + +" Debugging +command! DebugToggleBreakpoint lua require'dap'.toggle_breakpoint() +command! DebugStart lua require'dap'.continue() +command! DebugContinue lua require'dap'.continue() +command! DebugStepOver lua require'dap'.step_over() +command! DebugStepOut lua require'dap'.step_out() +command! DebugStepInto lua require'dap'.step_into() +command! DebugToggleRepl lua require'dap'.repl.toggle() +command! DebugGetSession lua require'dap'.session() + +" Available Debug Adapters: +" https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ +" +" Adapter configuration and installation instructions: +" https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation +" +" Debug Adapter protocol: +" https://microsoft.github.io/debug-adapter-protocol/ + +" TODO Add full support later +" nnoremap :lua require'dap'.continue() +" nnoremap :lua require'dap'.step_over() +" nnoremap :lua require'dap'.step_into() +" nnoremap :lua require'dap'.step_out() +" nnoremap b :lua require'dap'.toggle_breakpoint() +" nnoremap B :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: ')) +" nnoremap lp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) +" nnoremap dr :lua require'dap'.repl.open() +" nnoremap dl :lua require'dap'.run_last() + +autocmd! User GoyoEnter lua require('gitsigns').toggle_signs() +autocmd! User GoyoLeave lua require('gitsigns').toggle_signs() + +autocmd User GoyoEnter set laststatus=0 +autocmd User GoyoLeave set laststatus=2 + +" autocmd! User GoyoEnter lua require('galaxyline').disable_galaxyline() +" autocmd! User GoyoLeave lua require('galaxyline').galaxyline_augroup() + +function! QuickFixToggle() + if empty(filter(getwininfo(), 'v:val.quickfix')) + copen + else + cclose + endif +endfunction diff --git a/nvim/vimscript/lv-vscode/init.vim b/nvim/vimscript/lv-vscode/init.vim new file mode 100644 index 0000000..1661d49 --- /dev/null +++ b/nvim/vimscript/lv-vscode/init.vim @@ -0,0 +1,84 @@ +" packadd quickscope + +execute 'luafile ' . stdpath('config') . '/lua/settings.lua' + +function! s:manageEditorSize(...) + let count = a:1 + let to = a:2 + for i in range(1, count ? count : 1) + call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize') + endfor +endfunction + +function! s:vscodeCommentary(...) abort + if !a:0 + let &operatorfunc = matchstr(expand(''), '[^. ]*$') + return 'g@' + elseif a:0 > 1 + let [line1, line2] = [a:1, a:2] + else + let [line1, line2] = [line("'["), line("']")] + endif + + call VSCodeCallRange("editor.action.commentLine", line1, line2, 0) +endfunction + +function! s:openVSCodeCommandsInVisualMode() + normal! gv + let visualmode = visualmode() + if visualmode == "V" + let startLine = line("v") + let endLine = line(".") + call VSCodeNotifyRange("workbench.action.showCommands", startLine, endLine, 1) + else + let startPos = getpos("v") + let endPos = getpos(".") + call VSCodeNotifyRangePos("workbench.action.showCommands", startPos[1], endPos[1], startPos[2], endPos[2], 1) + endif +endfunction + +function! s:openWhichKeyInVisualMode() + normal! gv + let visualmode = visualmode() + if visualmode == "V" + let startLine = line("v") + let endLine = line(".") + call VSCodeNotifyRange("whichkey.show", startLine, endLine, 1) + else + let startPos = getpos("v") + let endPos = getpos(".") + call VSCodeNotifyRangePos("whichkey.show", startPos[1], endPos[1], startPos[2], endPos[2], 1) + endif +endfunction + +" Better Navigation +nnoremap :call VSCodeNotify('workbench.action.navigateDown') +xnoremap :call VSCodeNotify('workbench.action.navigateDown') +nnoremap :call VSCodeNotify('workbench.action.navigateUp') +xnoremap :call VSCodeNotify('workbench.action.navigateUp') +nnoremap :call VSCodeNotify('workbench.action.navigateLeft') +xnoremap :call VSCodeNotify('workbench.action.navigateLeft') +nnoremap :call VSCodeNotify('workbench.action.navigateRight') +xnoremap :call VSCodeNotify('workbench.action.navigateRight') + +nnoremap gr call VSCodeNotify('editor.action.goToReferences') + +" Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors +" xnoremap vscodeCommentary() +" nnoremap vscodeCommentary() . '_' + +nnoremap _ :call VSCodeNotify('workbench.action.toggleEditorWidths') + +nnoremap :call VSCodeNotify('whichkey.show') +xnoremap :call openWhichKeyInVisualMode() + +xnoremap :call openVSCodeCommandsInVisualMode() + +xmap gc VSCodeCommentary +nmap gc VSCodeCommentary +omap gc VSCodeCommentary +nmap gcc VSCodeCommentaryLine + +" Simulate same TAB behavior in VSCode +nmap :Tabnext +nmap :Tabprev diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..14bd3d4 --- /dev/null +++ b/setup.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +import os +import argparse + +home_dir = os.getenv("HOME") + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-i","--install", help="install tools",type=str) + args = parser.parse_args() + installer = Installer() + installer.install(args.install) + +class Base(object): + def cmd_exist(self, name): + from shutil import which + return which(name) is not None + + def check_link(self, name:str,target:str): + if os.path.islink(name): + t = os.readlink(name) + if t == target: + return + os.system("mv %s %s.bak"%(name,name)) + os.system("ln -s %s %s"%(target,name)) +class Installer(Base): + def install(self, val:str): + if val== "": + print("install value is empty") + exit() + + install_map = { + "neovim": self.install_neovim, + "z": self.install_z, + "git": self.install_git, + "packer": self.install_packer, + } + if val in install_map: + install_map.get(val)() + else: + print("cmd not support, install: "+val) + + + # install neovim + def install_neovim(self): + if not self.cmd_exist("nvim"): + os.chdir("/usr/local") + os.system("wget https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-macos.tar.gz") + os.system("tar zxf nvim-macos.tar.gz") + os.system("ln -s /usr/local/nvim-osx64 /usr/local/nvim") + self.check_link(home_dir+"/.config/nvim",home_dir+"/.doftile/nvim") + + def install_z(self): + if not os.path.exists("/usr/local/z.lua"): + os.system("git clone --depth=1 https://github.com/skywind3000/z.lua.git /usr/local/z.lua") + + def install_git(self): + if not self.cmd_exist("git"): + print("git is not exist") + self.check_link(home_dir+"~/.gitconfig", home_dir+"/.dotfile/git/.gitconfig") + + def install_packer(self): + if not os.path.exists(home_dir+"/.local/share/nvim/site/pack/packer/start/packer.nvim"): + os.system("git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim") + else: + print("packer already installed") +class Base(object): + def cmd_exist(self, name): + from shutil import which + return which(name) is not None + + def check_link(self, name:str,target:str): + if os.path.islink(name): + t = os.readlink(name) + if t == target: + print("path is right: %s"%name) + return + os.system("mv %s %s.bak"%(name,name)) + os.system("ln -s %s %s"%(target,name)) + + + + + + +if __name__ == '__main__': + main()