diff options
Diffstat (limited to '.config/nvim/lua')
-rw-r--r-- | .config/nvim/lua/_autopairs/init.lua | 97 | ||||
-rw-r--r-- | .config/nvim/lua/_compe/init.lua | 115 | ||||
-rw-r--r-- | .config/nvim/lua/_galaxyline/init.lua | 435 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/bash-ls.lua | 2 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/docker-ls.lua | 2 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/init.lua | 68 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/json-ls.lua | 11 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/lua-ls.lua | 45 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/python-ls.lua | 4 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/vim-ls.lua | 2 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/yaml-ls.lua | 4 | ||||
-rw-r--r-- | .config/nvim/lua/_nvimtree/init.lua | 99 | ||||
-rw-r--r-- | .config/nvim/lua/_rnvimr/init.lua | 18 | ||||
-rw-r--r-- | .config/nvim/lua/_startify/init.lua | 41 | ||||
-rw-r--r-- | .config/nvim/lua/_telescope/init.lua | 1 | ||||
-rw-r--r-- | .config/nvim/lua/_treesitter/init.lua | 27 | ||||
-rw-r--r-- | .config/nvim/lua/_utils/init.lua | 110 | ||||
-rw-r--r-- | .config/nvim/lua/colorscheme.lua | 10 | ||||
-rw-r--r-- | .config/nvim/lua/plugins.lua | 226 | ||||
-rw-r--r-- | .config/nvim/lua/settings.lua | 82 |
20 files changed, 610 insertions, 789 deletions
diff --git a/.config/nvim/lua/_autopairs/init.lua b/.config/nvim/lua/_autopairs/init.lua index 6810a77..5d0adf8 100644 --- a/.config/nvim/lua/_autopairs/init.lua +++ b/.config/nvim/lua/_autopairs/init.lua @@ -1,40 +1,77 @@ require('nvim-autopairs').setup() - -local pairs_map = { - ["'"] = "'", - ['"'] = '"', - ['('] = ')', - ['['] = ']', - ['{'] = '}', - ['`'] = '`', -} -local disable_filetype = { "TelescopePrompt" } -local break_line_filetype = nil -- mean all file type -local html_break_line_filetype = {'html' , 'vue' , 'typescriptreact' , 'svelte' , 'javascriptreact'} -local ignored_next_char = "%w" - -local remap = vim.api.nvim_set_keymap local npairs = require('nvim-autopairs') --- skip it, if you use another global object -_G.MUtils= {} +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("<c-y>") +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("<c-y>") + return npairs.esc("") + else + vim.defer_fn(function() + vim.fn["compe#confirm"]("<cr>") + end, 20) + return npairs.esc("<c-n>") + 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("<c-n>") + end else - vim.defer_fn(function() - vim.fn["compe#confirm"]("<cr>") - end, 20) - return npairs.esc("<c-n>") + return npairs.check_break_line_char() end - else - return npairs.check_break_line_char() - end end +MUtils.tab = function() + if vim.fn.pumvisible() ~= 0 then + return npairs.esc("<C-n>") + 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("<Tab>") + end + end +end + +MUtils.s_tab = function() + if vim.fn.pumvisible() ~= 0 then + return npairs.esc("<C-p>") + 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("<C-h>") + end + end +end -remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true}) +-- Autocompletion and snippets +vim.api.nvim_set_keymap('i', '<CR>', 'v:lua.MUtils.completion_confirm()', {expr = true, noremap = true}) +-- imap("<CR>", "v:lua.MUtils.completion_confirm()", {expr = true, noremap = true}) +imap("<Tab>", "v:lua.MUtils.tab()", {expr = true, noremap = true}) +imap("<S-Tab>", "v:lua.MUtils.s_tab()", {expr = true, noremap = true}) diff --git a/.config/nvim/lua/_compe/init.lua b/.config/nvim/lua/_compe/init.lua index 75fa9b5..6127096 100644 --- a/.config/nvim/lua/_compe/init.lua +++ b/.config/nvim/lua/_compe/init.lua @@ -1,39 +1,66 @@ 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; + enabled = O.auto_complete, + 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 = true; - buffer = true; - calc = true; - vsnip = true; - nvim_lsp = true; - nvim_lua = true; - spell = true; - tags = true; - snippets_nvim = true; - treesitter = true; - }; + source = { + path = {kind = " "}, + buffer = {kind = " "}, + calc = {kind = " "}, + vsnip = {kind = " "}, + nvim_lsp = {kind = " "}, + -- nvim_lua = {kind = " "}, + nvim_lua = false, + spell = {kind = " "}, + tags = false, + vim_dadbod_completion = true, + -- snippets_nvim = {kind = " "}, + -- ultisnips = {kind = " "}, + -- treesitter = {kind = " "}, + emoji = {kind = " ﲃ ", 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) + return vim.api.nvim_replace_termcodes(str, true, true, true) end local check_back_space = function() @@ -49,24 +76,24 @@ end --- 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 "<C-n>" - elseif vim.fn.call("vsnip#available", {1}) == 1 then - return t "<Plug>(vsnip-expand-or-jump)" - elseif check_back_space() then - return t "<Tab>" - else - return vim.fn['compe#complete']() - end + if vim.fn.pumvisible() == 1 then + return t "<C-n>" + elseif vim.fn.call("vsnip#available", {1}) == 1 then + return t "<Plug>(vsnip-expand-or-jump)" + elseif check_back_space() then + return t "<Tab>" + else + return vim.fn['compe#complete']() + end end _G.s_tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "<C-p>" - elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then - return t "<Plug>(vsnip-jump-prev)" - else - return t "<S-Tab>" - end + if vim.fn.pumvisible() == 1 then + return t "<C-p>" + elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then + return t "<Plug>(vsnip-jump-prev)" + else + return t "<S-Tab>" + end end vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true}) diff --git a/.config/nvim/lua/_galaxyline/init.lua b/.config/nvim/lua/_galaxyline/init.lua index 44801cf..f9ac859 100644 --- a/.config/nvim/lua/_galaxyline/init.lua +++ b/.config/nvim/lua/_galaxyline/init.lua @@ -1,233 +1,208 @@ -local cmd = vim.cmd -local fn = vim.fn -local gl = require("galaxyline") -local section = gl.section -gl.short_line_list = {"LuaTree", "packager", "Floaterm", "coc-eplorer"} +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'} +gls.left[1] = { + 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') -local colors = { - bg = "#0f1419", - fg = "#d0d0d0", - line_bg = "#0f1419", - fg_green = "#90a959", - yellow = "#f4bf75", - cyan = "#75b5aa", - darkblue = "#6a9fb5", - green = "#90a959", - orange = "#D08770", - purple = "#B48EAD", - magenta = "#aa759f", - gray = "#505050", - blue = "#6a9fb5", - red = "#ac4142" -} - -local buffer_not_empty = function() - if fn.empty(fn.expand("%:t")) ~= 1 then - return true - end - return false -end - -section.left[1] = { - FirstElement = { - -- provider = function() return '▊ ' end, - provider = function() - return " " - end, - highlight = {colors.blue, colors.line_bg} - } -} -section.left[2] = { - ViMode = { - provider = function() - -- auto change color according the vim mode - local mode_color = { - n = colors.magenta, - i = colors.green, - v = colors.blue, - [""] = colors.blue, - V = colors.blue, - c = colors.red, - no = colors.magenta, - s = colors.orange, - S = colors.orange, - [""] = colors.orange, - ic = colors.yellow, - R = colors.purple, - Rv = colors.purple, - cv = colors.red, - ce = colors.red, - r = colors.cyan, - rm = colors.cyan, - ["r?"] = colors.cyan, - ["!"] = colors.red, - t = colors.red - } - cmd("hi GalaxyViMode guifg=" .. mode_color[fn.mode()]) - return " " - end, - highlight = {colors.red, colors.line_bg, "bold"} - } -} -section.left[3] = { - FileIcon = { - provider = "FileIcon", - condition = buffer_not_empty, - highlight = {require("galaxyline.provider_fileinfo").get_file_icon_color, colors.line_bg} - } -} -section.left[4] = { - FileName = { - -- provider = "FileName", - provider = function() - return fn.expand("%:F") - end, - condition = buffer_not_empty, - separator = " ", - separator_highlight = {colors.purple, colors.bg}, - highlight = {colors.purple, colors.line_bg, "bold"} - } -} - -section.right[1] = { - GitIcon = { - provider = function() - return " " - end, - condition = require("galaxyline.provider_vcs").check_git_workspace, - highlight = {colors.orange, colors.line_bg} - } -} -section.right[2] = { - GitBranch = { - provider = "GitBranch", - condition = require("galaxyline.provider_vcs").check_git_workspace, - separator = "", - separator_highlight = {colors.purple, colors.bg}, - highlight = {colors.orange, colors.line_bg, "bold"} - } -} - -local checkwidth = function() - local squeeze_width = fn.winwidth(0) / 2 - if squeeze_width > 40 then - return true - end - return false -end - -section.right[3] = { - DiffAdd = { - provider = "DiffAdd", - condition = checkwidth, - icon = " ", - highlight = {colors.green, colors.line_bg} - } -} -section.right[4] = { - DiffModified = { - provider = "DiffModified", - condition = checkwidth, - icon = "柳", - highlight = {colors.yellow, colors.line_bg} - } -} -section.right[5] = { - DiffRemove = { - provider = "DiffRemove", - condition = checkwidth, - icon = " ", - highlight = {colors.red, colors.line_bg} - } -} - -section.right[6] = { - LineInfo = { - provider = "LineColumn", - separator = "", - separator_highlight = {colors.blue, colors.line_bg}, - highlight = {colors.gray, colors.line_bg} - } -} --- section.right[7] = { --- FileSize = { --- provider = "FileSize", --- separator = " ", --- condition = buffer_not_empty, --- separator_highlight = {colors.blue, colors.line_bg}, --- highlight = {colors.fg, colors.line_bg} --- } --- } - -section.right[8] = { - DiagnosticError = { - provider = "DiagnosticError", - separator = " ", - icon = " ", - highlight = {colors.red, colors.line_bg}, - separator_highlight = {colors.bg, colors.bg} - } -} -section.right[9] = { - DiagnosticWarn = { - provider = "DiagnosticWarn", - -- separator = " ", - icon = " ", - highlight = {colors.yellow, colors.line_bg}, - separator_highlight = {colors.bg, colors.bg} - } -} - -section.right[10] = { - DiagnosticInfo = { - -- separator = " ", - provider = "DiagnosticInfo", - icon = " ", - highlight = {colors.green, colors.line_bg}, - separator_highlight = {colors.bg, colors.bg} - } -} - -section.right[11] = { - DiagnosticHint = { - provider = "DiagnosticHint", - -- separator = " ", - icon = " ", - highlight = {colors.blue, colors.line_bg}, - separator_highlight = {colors.bg, colors.bg} - } -} - -section.short_line_left[1] = { - BufferType = { - provider = 'FileTypeName', - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.blue,colors.bg,'bold'} - } -} - -section.short_line_left[2] = { - SFileName = { - provider = function () - local fileinfo = require('galaxyline.provider_fileinfo') - local fname = fileinfo.get_current_file_name() - for _,v in ipairs(gl.short_line_list) do - if v == vim.bo.filetype then - return '' - end - end - return fname - end, - condition = buffer_not_empty, - highlight = {colors.white,colors.bg,'bold'} - } -} - -section.short_line_right[1] = { - BufferIcon = { - provider= 'BufferIcon', - highlight = {colors.fg,colors.bg} - } +gls.left[2] = { + GitIcon = { + provider = function() + return ' ' + end, + condition = condition.check_git_workspace, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.orange, colors.bg} + } +} + +gls.left[3] = { + GitBranch = { + provider = 'GitBranch', + condition = condition.check_git_workspace, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +} + +gls.left[4] = { + DiffAdd = { + provider = 'DiffAdd', + condition = condition.hide_in_width, + icon = ' ', + highlight = {colors.green, colors.bg} + } +} +gls.left[5] = { + DiffModified = { + provider = 'DiffModified', + condition = condition.hide_in_width, + icon = ' 柳', + highlight = {colors.blue, colors.bg} + } +} +gls.left[6] = { + DiffRemove = { + provider = 'DiffRemove', + condition = condition.hide_in_width, + icon = ' ', + highlight = {colors.red, colors.bg} + } +} + +gls.right[1] = { + DiagnosticError = {provider = 'DiagnosticError', icon = ' ', highlight = {colors.error_red, colors.bg}} +} +gls.right[2] = {DiagnosticWarn = {provider = 'DiagnosticWarn', icon = ' ', highlight = {colors.orange, colors.bg}}} + +gls.right[3] = { + DiagnosticHint = {provider = 'DiagnosticHint', icon = ' ', highlight = {colors.vivid_blue, colors.bg}} +} + +gls.right[4] = {DiagnosticInfo = {provider = 'DiagnosticInfo', icon = ' ', highlight = {colors.info_yellow, colors.bg}}} + +gls.right[5] = { + 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} + } +} + +gls.right[6] = { + LineInfo = { + provider = 'LineColumn', + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } } + +gls.right[7] = { + PerCent = { + provider = 'LinePercent', + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +} + +gls.right[8] = { + 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} + } +} + +gls.right[9] = { + BufferType = { + provider = 'FileTypeName', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +} + +gls.right[10] = { + FileEncode = { + provider = 'FileEncode', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +} + +gls.right[11] = { + Space = { + provider = function() + return ' ' + end, + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.orange, colors.bg} + } +} + +gls.short_line_left[1] = { + BufferType = { + provider = 'FileTypeName', + separator = ' ', + separator_highlight = {'NONE', colors.bg}, + highlight = {colors.grey, colors.bg} + } +} + +gls.short_line_left[2] = { + SFileName = {provider = 'SFileName', condition = condition.buffer_not_empty, highlight = {colors.grey, colors.bg}} +} + +gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}} diff --git a/.config/nvim/lua/_lsp/bash-ls.lua b/.config/nvim/lua/_lsp/bash-ls.lua deleted file mode 100644 index 7a12dc0..0000000 --- a/.config/nvim/lua/_lsp/bash-ls.lua +++ /dev/null @@ -1,2 +0,0 @@ --- npm i -g bash-language-server -require'lspconfig'.bashls.setup {on_attach = require'_lsp'.common_on_attach} diff --git a/.config/nvim/lua/_lsp/docker-ls.lua b/.config/nvim/lua/_lsp/docker-ls.lua deleted file mode 100644 index 878aa86..0000000 --- a/.config/nvim/lua/_lsp/docker-ls.lua +++ /dev/null @@ -1,2 +0,0 @@ --- npm install -g dockerfile-language-server-nodejs -require'lspconfig'.dockerls.setup {on_attach = require'_lsp'.common_on_attach} diff --git a/.config/nvim/lua/_lsp/init.lua b/.config/nvim/lua/_lsp/init.lua deleted file mode 100644 index 12ce36a..0000000 --- a/.config/nvim/lua/_lsp/init.lua +++ /dev/null @@ -1,68 +0,0 @@ --- 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("LspDiagnosticsSignInformation", { - texthl = "LspDiagnosticsSignInformation", - text = "", - numhl = "LspDiagnosticsSignInformation" -}) -vim.fn.sign_define("LspDiagnosticsSignHint", { - texthl = "LspDiagnosticsSignHint", - text = "", - numhl = "LspDiagnosticsSignHint" -}) - -vim.cmd('nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>') -vim.cmd('nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>') -vim.cmd('nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>') -vim.cmd('nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>') -vim.cmd('nnoremap <silent> ca :Lspsaga code_action<CR>') -vim.cmd('nnoremap <silent> K :Lspsaga hover_doc<CR>') --- vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>') -vim.cmd('nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>') -vim.cmd('nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>') --- scroll down hover doc or scroll in definition preview -vim.cmd('nnoremap <silent> <C-f> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(1)<CR>') --- scroll up hover doc -vim.cmd('nnoremap <silent> <C-b> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(-1)<CR>') -vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') - ---[[ " 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 <Cmd>lua require('jdtls').code_action()<CR> - -local lsp_config = {} - -function lsp_config.common_on_attach(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! * <buffer> - autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() - autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() - augroup END - ]], false) - end -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/.config/nvim/lua/_lsp/json-ls.lua b/.config/nvim/lua/_lsp/json-ls.lua deleted file mode 100644 index 4fbbeff..0000000 --- a/.config/nvim/lua/_lsp/json-ls.lua +++ /dev/null @@ -1,11 +0,0 @@ --- npm install -g vscode-json-languageserver -require'lspconfig'.jsonls.setup { - 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/.config/nvim/lua/_lsp/lua-ls.lua b/.config/nvim/lua/_lsp/lua-ls.lua deleted file mode 100644 index 5768e5d..0000000 --- a/.config/nvim/lua/_lsp/lua-ls.lua +++ /dev/null @@ -1,45 +0,0 @@ - -- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) -USER = vim.fn.expand('$USER') - -local sumneko_root_path = "" -local sumneko_binary = "" - -if vim.fn.has("mac") == 1 then - sumneko_root_path = "/Users/" .. USER .. - "/.config/nvim/ls/lua-language-server" - sumneko_binary = "/Users/" .. USER .. - "/.config/nvim/ls/lua-language-server/bin/macOS/lua-language-server" -elseif vim.fn.has("unix") == 1 then - sumneko_root_path = "/home/" .. USER .. - "/.config/nvim/ls/lua-language-server" - sumneko_binary = "/home/" .. USER .. - "/.config/nvim/ls/lua-language-server/bin/Linux/lua-language-server" -else - print("Unsupported system for sumneko") -end - -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 - } - } - } - } -} diff --git a/.config/nvim/lua/_lsp/python-ls.lua b/.config/nvim/lua/_lsp/python-ls.lua deleted file mode 100644 index d07f59b..0000000 --- a/.config/nvim/lua/_lsp/python-ls.lua +++ /dev/null @@ -1,4 +0,0 @@ --- npm i -g pyright -require'lspconfig'.pyright.setup{ - on_attach = require'_lsp'.common_on_attach, -} diff --git a/.config/nvim/lua/_lsp/vim-ls.lua b/.config/nvim/lua/_lsp/vim-ls.lua deleted file mode 100644 index 08039a3..0000000 --- a/.config/nvim/lua/_lsp/vim-ls.lua +++ /dev/null @@ -1,2 +0,0 @@ --- npm install -g vim-language-server -require'lspconfig'.vimls.setup {on_attach = require'_lsp'.common_on_attach} diff --git a/.config/nvim/lua/_lsp/yaml-ls.lua b/.config/nvim/lua/_lsp/yaml-ls.lua deleted file mode 100644 index e611572..0000000 --- a/.config/nvim/lua/_lsp/yaml-ls.lua +++ /dev/null @@ -1,4 +0,0 @@ --- npm install -g yaml-language-server -require'lspconfig'.yamlls.setup{ - -- on_attach = require'lsp'.common_on_attach, -} diff --git a/.config/nvim/lua/_nvimtree/init.lua b/.config/nvim/lua/_nvimtree/init.lua index 997ade6..11fe526 100644 --- a/.config/nvim/lua/_nvimtree/init.lua +++ b/.config/nvim/lua/_nvimtree/init.lua @@ -1,54 +1,49 @@ ---[[ " ---let g:nvim_tree_auto_ignore_ft = 'startify' "empty by default, don't auto open tree on specific filetypes. -let g:nvim_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.` -let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons). -" let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open -" let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file -let g:nvim_tree_show_icons = { - \ 'git': 1, - \ 'folders': 1, - \ 'files': 1, - \ } -"If 0, do not show the icons for one of 'git' 'folder' and 'files' -"1 by default, notice that if 'files' is 1, it will only display -"if nvim-web-devicons is installed and on your runtimepath ]] --- vim.g.nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default -vim.g.nvim_tree_disable_netrw = 0 --"1 by default, disables netrw --- vim.g.nvim_tree_hijack_netrw = 0 --"1 by default, prevents netrw from automatically opening when opening directories (but lets you keep its other utilities) -vim.g.nvim_tree_hide_dotfiles = 1 --0 by default, this option hides files and folders starting with a dot `.` -vim.g.nvim_tree_indent_markers = 1 --"0 by default, this option shows indent markers when folders are open -vim.g.nvim_tree_follow = 1 --"0 by default, this option allows the cursor to be updated when entering a buffer -vim.g.nvim_tree_auto_close = 1 --0 by default, closes the tree when it's the last window -vim.g.nvim_tree_auto_ignore_ft = 'startify' --"empty by default, don't auto open tree on specific filetypes. +vim.g.nvim_tree_disable_netrw = 0 -- "1 by default, disables netrw +vim.g.nvim_tree_hide_dotfiles = 1 -- 0 by default, this option hides files and folders starting with a dot `.` +vim.g.nvim_tree_indent_markers = 1 -- "0 by default, this option shows indent markers when folders are open +vim.g.nvim_tree_follow = 1 -- "0 by default, this option allows the cursor to be updated when entering a buffer +vim.g.nvim_tree_auto_close = O.auto_close_tree -- 0 by default, closes the tree when it's the last window +vim.g.nvim_tree_auto_ignore_ft = 'startify' --empty by default, don't auto open tree on specific filetypes. local tree_cb = require'nvim-tree.config'.nvim_tree_callback -vim.g.nvim_tree_bindings = { - -- mappings - ["<CR>"] = tree_cb("edit"), - ["l"] = tree_cb("edit"), - ["o"] = tree_cb("edit"), - ["<2-LeftMouse>"] = tree_cb("edit"), - ["<2-RightMouse>"] = tree_cb("cd"), - ["<C-]>"] = tree_cb("cd"), - ["v"] = tree_cb("vsplit"), - ["s"] = tree_cb("split"), - ["<C-t>"] = tree_cb("tabnew"), - ["h"] = tree_cb("close_node"), - ["<BS>"] = tree_cb("close_node"), - ["<S-CR>"] = tree_cb("close_node"), - ["<Tab>"] = tree_cb("preview"), - ["I"] = tree_cb("toggle_ignored"), - ["H"] = tree_cb("toggle_dotfiles"), - ["R"] = tree_cb("refresh"), - ["a"] = tree_cb("create"), - ["d"] = tree_cb("remove"), - ["r"] = tree_cb("rename"), - ["<C-r>"] = tree_cb("full_rename"), - ["x"] = tree_cb("cut"), - ["c"] = tree_cb("copy"), - ["p"] = tree_cb("paste"), - ["[c"] = tree_cb("prev_git_item"), - ["]c"] = tree_cb("next_git_item"), - ["-"] = tree_cb("dir_up"), - ["q"] = tree_cb("close") + vim.g.nvim_tree_bindings = { + -- ["<CR>"] = ":YourVimFunction()<cr>", + -- ["u"] = ":lua require'some_module'.some_function()<cr>", + + -- default mappings + ["<CR>"] = tree_cb("edit"), + ["o"] = tree_cb("edit"), + ["l"] = tree_cb("edit"), + ["<2-LeftMouse>"] = tree_cb("edit"), + ["<2-RightMouse>"] = tree_cb("cd"), + ["<C-]>"] = tree_cb("cd"), + ["<C-v>"] = tree_cb("vsplit"), + ["<C-x>"] = tree_cb("split"), + ["<C-t>"] = tree_cb("tabnew"), + ["<"] = tree_cb("prev_sibling"), + [">"] = tree_cb("next_sibling"), + ["<BS>"] = tree_cb("close_node"), + ["h"] = tree_cb("close_node"), + ["<S-CR>"] = tree_cb("close_node"), + ["<Tab>"] = tree_cb("preview"), + ["I"] = tree_cb("toggle_ignored"), + ["H"] = tree_cb("toggle_dotfiles"), + ["R"] = tree_cb("refresh"), + ["a"] = tree_cb("create"), + ["d"] = tree_cb("remove"), + ["r"] = tree_cb("rename"), + ["<C-r>"] = tree_cb("full_rename"), + ["x"] = tree_cb("cut"), + ["c"] = tree_cb("copy"), + ["p"] = tree_cb("paste"), + ["[c"] = tree_cb("prev_git_item"), + ["]c"] = tree_cb("next_git_item"), + ["-"] = tree_cb("dir_up"), + ["q"] = tree_cb("close"), + } +-- 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 = "", empty = "", empty_open = "", symlink = ""} } -vim.cmd([[source ~/.config/nvim/vim-script/_nvimtree/init.vim]]) diff --git a/.config/nvim/lua/_rnvimr/init.lua b/.config/nvim/lua/_rnvimr/init.lua index 055326c..f84bde9 100644 --- a/.config/nvim/lua/_rnvimr/init.lua +++ b/.config/nvim/lua/_rnvimr/init.lua @@ -1,22 +1,6 @@ -- Make Ranger replace netrw and be the file explorer vim.g.rnvimr_ex_enable = 1 vim.g.rnvimr_draw_border = 1 - --- Make Ranger to be hidden after picking a file vim.g.rnvimr_pick_enable = 1 - --- Make Neovim to wipe the buffers corresponding to the files deleted by Ranger vim.g.rnvimr_bw_enable = 1 - --- vim.cmd('nmap <leader>r :RnvimrToggle<CR>') - ---[[ let g:rnvimr_ranger_cmd = 'ranger --cmd="set column_ratios 1,1"' - " \ --cmd="set draw_borders separators"' -" let g:rnvimr_layout = { 'relative': 'editor', -" \ 'width': float2nr(round(0.6 * &columns)), -" \ 'height': float2nr(round(0.6 * &lines)), -" \ 'col': float2nr(round(0.2 * &columns)), -" \ 'row': float2nr(round(0.2 * &lines)), -" \ 'style': 'minimal' } -let g:rnvimr_presets = [ - \ {'width': 0.800, 'height': 0.800}] ]] +vim.api.nvim_set_keymap('n', '-', ':RnvimrToggle<CR>', {noremap = true, silent = true}) diff --git a/.config/nvim/lua/_startify/init.lua b/.config/nvim/lua/_startify/init.lua deleted file mode 100644 index 3f627a0..0000000 --- a/.config/nvim/lua/_startify/init.lua +++ /dev/null @@ -1,41 +0,0 @@ -vim.g.startify_custom_header = { - ' ##############..... ############## ', - ' ##############......############## ', - ' ##########..........########## ', - ' ##########........########## ', - ' ##########.......########## ', - ' ##########.....##########.. ', - ' ##########....##########..... ', - ' ..##########..##########......... ', - ' ....##########.#########............. ', - ' ..################JJJ............ ', - ' ################............. ', - ' ##############.JJJ.JJJJJJJJJJ ', - ' ############...JJ...JJ..JJ JJ ', - ' ##########....JJ...JJ..JJ JJ ', - ' ########......JJJ..JJJ JJJ JJJ ', - ' ###### ......... ', - ' ..... ', - ' . ', - } - -vim.g.webdevicons_enable_startify = 1 -vim.g.startify_enable_special = 0 -vim.g.startify_session_dir = '~/.config/nvim/session' -vim.g.startify_session_autoload = 1 -vim.g.startify_session_delete_buffers = 1 -vim.g.startify_change_to_vcs_root = 1 -vim.g.startify_fortune_use_unicode = 1 -vim.g.startify_session_persistence = 1 -vim.g.startify_session_dir = '~/.config/nvim/session' - - -vim.api.nvim_exec('let startify_lists = [ { \'type\': \'files\', \'header\': [\' Files\'] }, { \'type\': \'sessions\', \'header\': [\' Sessions\'] }, { \'type\': \'bookmarks\', \'header\': [\' Bookmarks\'] }, ]',true) - -vim.api.nvim_exec('let startify_bookmarks = [ { \'i\': \'~/.config/nvim/init.lua\' }, { \'z\': \'~/.zshrc\' }]', true) - -vim.cmd([[ -function! StartifyEntryFormat() - return 'WebDevIconsGetFileTypeSymbol(absolute_path) ." ". entry_path' -endfunction -]]) diff --git a/.config/nvim/lua/_telescope/init.lua b/.config/nvim/lua/_telescope/init.lua index 416419f..744fdbf 100644 --- a/.config/nvim/lua/_telescope/init.lua +++ b/.config/nvim/lua/_telescope/init.lua @@ -2,7 +2,6 @@ local actions = require('telescope.actions') -- Global remapping ------------------------------ -- '--color=never', -require('telescope').load_extension('media_files') require('telescope').setup { defaults = { vimgrep_arguments = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'}, diff --git a/.config/nvim/lua/_treesitter/init.lua b/.config/nvim/lua/_treesitter/init.lua index 2b61051..b215e30 100644 --- a/.config/nvim/lua/_treesitter/init.lua +++ b/.config/nvim/lua/_treesitter/init.lua @@ -1,20 +1,11 @@ require'nvim-treesitter.configs'.setup { - ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages - highlight = { - enable = true, -- false will disable the whole extension - }, - playground = { - enable = true, - disable = {}, - updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code - persist_queries = false -- Whether the query persists across vim sessions - }, - rainbow = { - enable = false - }, - refactor = { - highlight_definitions = { - enable = false - } - } + ensure_installed = O.treesitter.ensure_installed, -- one of "all", "maintained" (parsers with maintainers), or a list of languages + ignore_install = O.treesitter.ignore_install, + highlight = { + enable = O.treesitter.highlight.enabled -- false will disable the whole extension + }, + -- indent = {enable = true, disable = {"python", "html", "javascript"}}, + -- TODO seems to be broken + indent = {enable = {"javascriptreact"}}, + autotag = {enable = true}, } diff --git a/.config/nvim/lua/_utils/init.lua b/.config/nvim/lua/_utils/init.lua index 43bbf2e..4d5c890 100644 --- a/.config/nvim/lua/_utils/init.lua +++ b/.config/nvim/lua/_utils/init.lua @@ -1,6 +1,6 @@ -local _utils = {} +local nv_utils = {} -function _utils.define_augroups(definitions) -- {{{1 +function nv_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 @@ -21,183 +21,169 @@ function _utils.define_augroups(definitions) -- {{{1 vim.cmd('augroup END') end end -_utils.define_augroups({ - _general_settings = { - { - 'TextYankPost', '*', - 'lua require(\'vim.highlight\').on_yank({higroup = \'QuickScopePrimary\', 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'}, - -- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'}, - -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'}, - }, - numbertoggle = { - {'BufEnter,FocusGained,InsertLeave', '*', 'set relativenumber'}, - {'BufLeave,FocusLost,InsertEnter', '*', 'set norelativenumber'}, - }, -}) --- Add this to lightbulb, java makes this annoying tho --- autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb() -- lsp -function _utils.add_to_workspace_folder() +function nv_utils.add_to_workspace_folder() vim.lsp.buf.add_workspace_folder() - end -function _utils.clear_references() +function nv_utils.clear_references() vim.lsp.buf.clear_references() end -function _utils.code_action() +function nv_utils.code_action() vim.lsp.buf.code_action() end -function _utils.declaration() +function nv_utils.declaration() vim.lsp.buf.declaration() vim.lsp.buf.clear_references() end -function _utils.definition() +function nv_utils.definition() vim.lsp.buf.definition() vim.lsp.buf.clear_references() end -function _utils.document_highlight() +function nv_utils.document_highlight() vim.lsp.buf.document_highlight() end -function _utils.document_symbol() +function nv_utils.document_symbol() vim.lsp.buf.document_symbol() end -function _utils.formatting() +function nv_utils.formatting() vim.lsp.buf.formatting() end -function _utils.formatting_sync() +function nv_utils.formatting_sync() vim.lsp.buf.formatting_sync() end -function _utils.hover() +function nv_utils.hover() vim.lsp.buf.hover() end -function _utils.implementation() +function nv_utils.implementation() vim.lsp.buf.implementation() end -function _utils.incoming_calls() +function nv_utils.incoming_calls() vim.lsp.buf.incoming_calls() end -function _utils.list_workspace_folders() +function nv_utils.list_workspace_folders() vim.lsp.buf.list_workspace_folders() end -function _utils.outgoing_calls() +function nv_utils.outgoing_calls() vim.lsp.buf.outgoing_calls() end -function _utils.range_code_action() +function nv_utils.range_code_action() vim.lsp.buf.range_code_action() end -function _utils.range_formatting() +function nv_utils.range_formatting() vim.lsp.buf.range_formatting() end -function _utils.references() +function nv_utils.references() vim.lsp.buf.references() vim.lsp.buf.clear_references() end -function _utils.remove_workspace_folder() +function nv_utils.remove_workspace_folder() vim.lsp.buf.remove_workspace_folder() end -function _utils.rename() +function nv_utils.rename() vim.lsp.buf.rename() end -function _utils.signature_help() +function nv_utils.signature_help() vim.lsp.buf.signature_help() end -function _utils.type_definition() +function nv_utils.type_definition() vim.lsp.buf.type_definition() end -function _utils.workspace_symbol() +function nv_utils.workspace_symbol() vim.lsp.buf.workspace_symbol() end -- diagnostic -function _utils.get_all() +function nv_utils.get_all() vim.lsp.diagnostic.get_all() end -function _utils.get_next() +function nv_utils.get_next() vim.lsp.diagnostic.get_next() end -function _utils.get_prev() +function nv_utils.get_prev() vim.lsp.diagnostic.get_prev() end -function _utils.goto_next() +function nv_utils.goto_next() vim.lsp.diagnostic.goto_next() end -function _utils.goto_prev() +function nv_utils.goto_prev() vim.lsp.diagnostic.goto_prev() end -function _utils.show_line_diagnostics() +function nv_utils.show_line_diagnostics() vim.lsp.diagnostic.show_line_diagnostics() end -- git signs -function _utils.next_hunk() +function nv_utils.next_hunk() require('gitsigns').next_hunk() end -function _utils.prev_hunk() +function nv_utils.prev_hunk() require('gitsigns').prev_hunk() end -function _utils.stage_hunk() +function nv_utils.stage_hunk() require('gitsigns').stage_hunk() end -function _utils.undo_stage_hunk() +function nv_utils.undo_stage_hunk() require('gitsigns').undo_stage_hunk() end -function _utils.reset_hunk() +function nv_utils.reset_hunk() require('gitsigns').reset_hunk() end -function _utils.reset_buffer() +function nv_utils.reset_buffer() require('gitsigns').reset_buffer() end -function _utils.preview_hunk() +function nv_utils.preview_hunk() require('gitsigns').preview_hunk() end -function _utils.blame_line() +function nv_utils.blame_line() require('gitsigns').blame_line() end -- misc +function nv_utils.file_exists(name) + local f = io.open(name, "r") + if f ~= nil then + io.close(f) + return true + else + return false + end +end --- autoformat --- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000) - -return _utils +return nv_utils diff --git a/.config/nvim/lua/colorscheme.lua b/.config/nvim/lua/colorscheme.lua index b160114..bfd467f 100644 --- a/.config/nvim/lua/colorscheme.lua +++ b/.config/nvim/lua/colorscheme.lua @@ -1,9 +1,3 @@ -local colorscheme = require('base16-colorscheme') +vim.cmd('let g:nvcode_termcolors=256') --- Or provide your own base16 colors -colorscheme.setup({ - base00 = '#0f1419', base01 = '#0f1419', base02 = '#3e4451', base03 = '#6c7891', - base04 = '#3e4451', base05 = '#abb2bf', base06 = '#9a9bb3', base07 = '#c5c8e6', - base08 = '#d7d7d7', base09 = '#d19a66', base0A = '#ffa657', base0B = '#afd7ff', - base0C = '#d7d7d7 ', base0D = '#afd7ff', base0E = '#ff875f', base0F = '#a06949', -}) +vim.cmd('colorscheme ' .. O.colorscheme) diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index cfed49f..4ff26c7 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -1,109 +1,131 @@ local execute = vim.api.nvim_command local fn = vim.fn -local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim' +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' + execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path) + execute "packadd packer.nvim" end -vim.cmd [[packadd packer.nvim]] - -vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' -- Auto compile when there are changes in plugins.lua - - -return require('packer').startup(function() - -- Packer can manage itself as an optional plugin - use {'wbthomason/packer.nvim'} - - -- Information - use 'nanotee/nvim-lua-guide' - - -- Quality of life improvements - use 'norcalli/nvim_utils' - - -- LSP - use 'neovim/nvim-lspconfig' - use 'glepnir/lspsaga.nvim' - use 'onsails/lspkind-nvim' - use 'kosayoda/nvim-lightbulb' - - -- Debugging - use 'mfussenegger/nvim-dap' - - -- Autocomplete - use 'hrsh7th/nvim-compe' - use 'hrsh7th/vim-vsnip' - use 'hrsh7th/vim-vsnip-integ' - - -- Treesitter - use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - use 'nvim-treesitter/playground' - use 'p00f/nvim-ts-rainbow' - - -- Icons - use 'kyazdani42/nvim-web-devicons' - use 'ryanoasis/vim-devicons' - - -- Status Line and Bufferline - use 'glepnir/galaxyline.nvim' - use {'akinsho/nvim-bufferline.lua', requires = 'kyazdani42/nvim-web-devicons'} - - -- Telescope - use 'nvim-lua/popup.nvim' - use 'nvim-lua/plenary.nvim' - use 'nvim-telescope/telescope.nvim' - use 'nvim-telescope/telescope-media-files.nvim' - - -- Explorer - use 'kyazdani42/nvim-tree.lua' - - -- Colorschemes - use 'aktersnurra/githubsy.vim' - use 'christianchiarulli/nvcode-color-schemes.vim' - use 'norcalli/nvim-colorizer.lua' - use 'RRethy/nvim-base16' - - -- Git - use 'TimUntersberger/neogit' - use {'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' } } - use 'f-person/git-blame.nvim' - use 'tpope/vim-fugitive' - use 'tpope/vim-rhubarb' - - -- Easily Create Gists - use 'mattn/vim-gist' - use 'mattn/webapi-vim' - - -- Registers - use 'gennaro-tedesco/nvim-peekup' - - -- General Plugins - use 'turbio/bracey.vim' - use 'metakirby5/codi.vim' - use 'windwp/nvim-autopairs' - use 'kevinhwang91/nvim-bqf' - use 'unblevable/quick-scope' - use 'airblade/vim-rooter' - use 'kevinhwang91/rnvimr' - use 'moll/vim-bbye' - use 'alvan/vim-closetag' - use 'voldikss/vim-floaterm' - use 'tpope/vim-sleuth' - use 'psliwka/vim-smoothie' - use 'mhinz/vim-startify' - use 'liuchengxu/vim-which-key' - use {'iamcco/markdown-preview.nvim', run = 'cd app && yarn install', cmd = 'MarkdownPreview'} - use 'AndrewRadev/tagalong.vim' - use 'liuchengxu/vista.vim' - use 'terrortylor/nvim-comment' - use 'bfredl/nvim-miniyank' - use 'andymass/vim-matchup' - use 'phaazon/hop.nvim' - use 'junegunn/goyo.vim' - use 'junegunn/limelight.vim' - use 'vimwiki/vimwiki' - use {'heavenshell/vim-pydocstring', run = 'make install'} - -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 + -- print(ok, err, code) + if ok then + vim.cmd("packadd " .. plugin) + 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 + -- 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 {"glepnir/lspsaga.nvim", opt = true} + use {"kabouzeid/nvim-lspinstall", 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-media-files.nvim", 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} + + -- Explorer + use "kyazdani42/nvim-tree.lua" + -- TODO remove when open on dir is supported by nvimtree + use "kevinhwang91/rnvimr" + + use {"liuchengxu/vim-which-key", opt = true} + use {"ChristianChiarulli/dashboard-nvim", opt = true} + use {"windwp/nvim-autopairs", opt = true} + use {"terrortylor/nvim-comment", opt = true} + use {"kevinhwang91/nvim-bqf", opt = true} + + -- Icons + use {"kyazdani42/nvim-web-devicons", opt = true} + + -- Status Line and Bufferline + use 'glepnir/galaxyline.nvim' + use {'akinsho/nvim-bufferline.lua', requires = 'kyazdani42/nvim-web-devicons'} + use {"romgrk/barbar.nvim", opt = true} + + -- Colorschemes + use 'aktersnurra/githubsy.vim' + use {"christianchiarulli/nvcode-color-schemes.vim", opt = true} + use 'norcalli/nvim-colorizer.lua' + use 'RRethy/nvim-base16' + + -- Git + use {"lewis6991/gitsigns.nvim", opt = true} + use 'TimUntersberger/neogit' + use 'f-person/git-blame.nvim' + use 'tpope/vim-fugitive' + use 'tpope/vim-rhubarb' + + -- Registers + use 'gennaro-tedesco/nvim-peekup' + + -- General Plugins + use 'turbio/bracey.vim' + use 'unblevable/quick-scope' + use 'airblade/vim-rooter' + use 'moll/vim-bbye' + use 'alvan/vim-closetag' + use 'voldikss/vim-floaterm' + use 'AndrewRadev/tagalong.vim' + use 'bfredl/nvim-miniyank' + use 'andymass/vim-matchup' + use 'phaazon/hop.nvim' + use 'junegunn/goyo.vim' + use 'vimwiki/vimwiki' + use {'heavenshell/vim-pydocstring', run = 'make install'} + + require_plugin("nvim-lspconfig") + require_plugin("lspsaga.nvim") + require_plugin("nvim-lspinstall") + require_plugin("popup.nvim") + require_plugin("plenary.nvim") + require_plugin("telescope.nvim") + require_plugin("nvim-dap") + require_plugin("nvim-compe") + require_plugin("vim-vsnip") + require_plugin("nvim-treesitter") + require_plugin("nvim-ts-autotag") + require_plugin("nvim-tree.lua") + require_plugin("gitsigns.nvim") + require_plugin("vim-which-key") + 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") + end +) diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index e75bb02..4f06694 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -1,47 +1,37 @@ -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.o.hidden=true --Required to keep multiple buffers open multiple buffers -vim.wo.wrap=false --Display long lines as just one line -vim.cmd('set whichwrap+=<,>,[,],h,l') -vim.o.encoding="utf-8" --The encoding displayed -vim.o.pumheight=10 --Makes popup menu smaller -vim.o.fileencoding="utf-8" --The encoding written to file -vim.o.ruler=true -- " Show the cursor position all the time -vim.o.cmdheight=2 --More space for displaying messages -vim.o.mouse="a" --Enable your mouse -vim.o.splitbelow=true --Horizontal splits will automatically be below -vim.o.termguicolors=true -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.o.tabstop=2 --Insert 2 spaces for a tab -vim.o.shiftwidth=2 --Change the number of space characters inserted for indentation -vim.o.smarttab=true --Makes tabbing smarter will realize you have 2 vs 4 -vim.o.expandtab=true --Converts tabs to spaces -vim.o.smartindent=true --Makes indenting smart -vim.o.autoindent=true --Good auto indent -vim.o.laststatus=2 --Always display the status line -vim.wo.number = true -vim.o.cursorline=true --Enable highlighting of the current line -vim.o.background="dark" --tell vim what the background color looks like -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.o.incsearch=true +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 = O.hidden_files -- 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 = O.wrap_lines -- Display long lines as just one line +vim.cmd('set whichwrap+=<,>,[,],h,l') -- move to next line with theses keys +vim.cmd('syntax on') -- move to next line with theses keys +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 giu 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.bo.expandtab = true -- Converts tabs to spaces +vim.bo.smartindent = true -- Makes indenting smart +vim.wo.number = O.number -- set numbered lines +vim.wo.relativenumber = O.relative_number -- 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.o.guifont="SpaceMono\\ Nerd\\ Font\\ Mono:h18" - --- relative line numbers --- vim.cmd('set number relativenumber') ---[[ local u = require('utils') - -u.define_augroups({ - numbertoggle = { - {'BufEnter', 'FocusGained', 'InsertLeave * set relativenumber'}, - {'BufLeave', 'FocusLost', 'InsertEnter * set norelativenumber'}, - }, -}) ]] |