From 8577c3b7cba714551d3537f3337ee2490bd20106 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sun, 14 Mar 2021 21:58:45 +0100 Subject: started moving to pure lua config --- .config/nvim/lua/_compe/init.lua | 70 +++++++++++ .config/nvim/lua/_telescope/init.lua | 83 +++++++++++++ .config/nvim/lua/bufferline/init.lua | 28 +++++ .config/nvim/lua/colorizer/init.lua | 13 ++ .config/nvim/lua/galaxyline/init.lua | 233 +++++++++++++++++++++++++++++++++++ .config/nvim/lua/lightbulb/init.lua | 36 ++++++ .config/nvim/lua/lsp/bash.lua | 2 + .config/nvim/lua/lsp/docker.lua | 2 + .config/nvim/lua/lsp/general.lua | 15 +++ .config/nvim/lua/lsp/json.lua | 10 ++ .config/nvim/lua/lsp/lsp-config.lua | 4 + .config/nvim/lua/lsp/lsp-kind.lua | 26 ++++ .config/nvim/lua/lsp/lua.lua | 37 ++++++ .config/nvim/lua/lsp/python.lua | 2 + .config/nvim/lua/lsp/vim.lua | 2 + .config/nvim/lua/lsp/wrapper.lua | 129 +++++++++++++++++++ .config/nvim/lua/lsp/yaml.lua | 2 + .config/nvim/lua/nvimtree/init.lua | 31 +++++ .config/nvim/lua/plug-colorizer.lua | 13 -- .config/nvim/lua/statusline.lua | 233 ----------------------------------- .config/nvim/lua/treesitter.lua | 15 --- .config/nvim/lua/treesitter/init.lua | 15 +++ 22 files changed, 740 insertions(+), 261 deletions(-) create mode 100644 .config/nvim/lua/_compe/init.lua create mode 100644 .config/nvim/lua/_telescope/init.lua create mode 100644 .config/nvim/lua/bufferline/init.lua create mode 100644 .config/nvim/lua/colorizer/init.lua create mode 100644 .config/nvim/lua/galaxyline/init.lua create mode 100644 .config/nvim/lua/lightbulb/init.lua create mode 100644 .config/nvim/lua/lsp/bash.lua create mode 100644 .config/nvim/lua/lsp/docker.lua create mode 100644 .config/nvim/lua/lsp/general.lua create mode 100644 .config/nvim/lua/lsp/json.lua create mode 100644 .config/nvim/lua/lsp/lsp-config.lua create mode 100644 .config/nvim/lua/lsp/lsp-kind.lua create mode 100644 .config/nvim/lua/lsp/lua.lua create mode 100644 .config/nvim/lua/lsp/python.lua create mode 100644 .config/nvim/lua/lsp/vim.lua create mode 100644 .config/nvim/lua/lsp/wrapper.lua create mode 100644 .config/nvim/lua/lsp/yaml.lua create mode 100644 .config/nvim/lua/nvimtree/init.lua delete mode 100644 .config/nvim/lua/plug-colorizer.lua delete mode 100644 .config/nvim/lua/statusline.lua delete mode 100644 .config/nvim/lua/treesitter.lua create mode 100644 .config/nvim/lua/treesitter/init.lua (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/_compe/init.lua b/.config/nvim/lua/_compe/init.lua new file mode 100644 index 0000000..d269be4 --- /dev/null +++ b/.config/nvim/lua/_compe/init.lua @@ -0,0 +1,70 @@ +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 = 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 + +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/.config/nvim/lua/_telescope/init.lua b/.config/nvim/lua/_telescope/init.lua new file mode 100644 index 0000000..4dfa57f --- /dev/null +++ b/.config/nvim/lua/_telescope/init.lua @@ -0,0 +1,83 @@ +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'}, + prompt_position = "top", + prompt_prefix = " ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "descending", + layout_strategy = "horizontal", + layout_defaults = {horizontal = {mirror = false}, 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 = { + { '─', '│', '─', '│', '┌', '┐', '┘', '└'}, + prompt = {"─", "│", " ", "│", '┌', '┐', "│", "│"}, + results = {"─", "│", "─", "│", "├", "┤", "┘", "└"}, + preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└'}, + }, + 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.move_selection_next, + [""] = actions.move_selection_previous, + -- To disable a keymap, put [map] = false + -- So, to not map "", just put + -- [""] = false, + + -- 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 + -- [""] = actions.close, + -- [""] = my_cool_custom_action, + } + } + }, + require'telescope'.setup { + extensions = { + media_files = { + -- filetypes whitelist + -- defaults to {"png", "jpg", "mp4", "webm", "pdf"} + filetypes = {"png", "webp", "jpg", "jpeg"}, + find_cmd = "rg" -- find command (defaults to `fd`) + } + } + } +} + +vim.api.nvim_set_keymap('n', 'ff', 'lua require("telescope.builtin").find_files()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'fg', 'lua require("telescope.builtin").live_grep()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'fb', 'lua require("telescope.builtin").buffers()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'fh', 'lua require("telescope.builtin").help_tags()', { noremap = true, silent = true }) diff --git a/.config/nvim/lua/bufferline/init.lua b/.config/nvim/lua/bufferline/init.lua new file mode 100644 index 0000000..ab7ecae --- /dev/null +++ b/.config/nvim/lua/bufferline/init.lua @@ -0,0 +1,28 @@ +require'bufferline'.setup{ + options = { + view = "default", + numbers = "none", + number_style = "superscript", + mappings = false, + buffer_close_icon= '', + modified_icon = '●', + close_icon = '', + left_trunc_marker = '', + right_trunc_marker = '', + max_name_length = 18, + max_prefix_length = 15, -- prefix used when a buffer is deduplicated + tab_size = 18, + diagnostics = "nvim_lsp", + show_buffer_close_icons = true, + show_tab_indicators = true, + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + -- can also be a table containing 2 custom separators + -- [focused and unfocused]. eg: { '|', '|' } + separator_style = "thin", + enforce_regular_tabs = false, + always_show_bufferline = true, + sort_by = 'relative_directory' + } +} +vim.api.nvim_set_keymap('n', '', ':BufferLineCycleNext', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', ':BufferLineCyclePrev', { noremap = true, silent = true }) diff --git a/.config/nvim/lua/colorizer/init.lua b/.config/nvim/lua/colorizer/init.lua new file mode 100644 index 0000000..1e25d7d --- /dev/null +++ b/.config/nvim/lua/colorizer/init.lua @@ -0,0 +1,13 @@ +require'colorizer'.setup( + {'*';}, + { + RGB = true; -- #RGB hex codes + RRGGBB = true; -- #RRGGBB hex codes + names = true; -- "Name" codes like Blue + 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 + }) + diff --git a/.config/nvim/lua/galaxyline/init.lua b/.config/nvim/lua/galaxyline/init.lua new file mode 100644 index 0000000..44801cf --- /dev/null +++ b/.config/nvim/lua/galaxyline/init.lua @@ -0,0 +1,233 @@ +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 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} + } +} diff --git a/.config/nvim/lua/lightbulb/init.lua b/.config/nvim/lua/lightbulb/init.lua new file mode 100644 index 0000000..1469c5b --- /dev/null +++ b/.config/nvim/lua/lightbulb/init.lua @@ -0,0 +1,36 @@ +-- Showing defaults +require'nvim-lightbulb'.update_lightbulb { + sign = { + enabled = true, + -- Priority of the gutter sign + priority = 10, + }, + float = { + enabled = false, + -- Text to show in the popup float + text = "💡", + -- Available keys for window options: + -- - height of floating window + -- - width of floating window + -- - wrap_at character to wrap at for computing height + -- - max_width maximal width of floating window + -- - max_height maximal height of floating window + -- - pad_left number of columns to pad contents at left + -- - pad_right number of columns to pad contents at right + -- - pad_top number of lines to pad contents at top + -- - pad_bottom number of lines to pad contents at bottom + -- - offset_x x-axis offset of the floating window + -- - offset_y y-axis offset of the floating window + -- - anchor corner of float to place at the cursor (NW, NE, SW, SE) + -- - winblend transparency of the window (0-100) + win_opts = {}, + }, + virtual_text = { + enabled = false, + -- Text to show at virtual text + text = "💡", + } +} + + +vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()]] diff --git a/.config/nvim/lua/lsp/bash.lua b/.config/nvim/lua/lsp/bash.lua new file mode 100644 index 0000000..8be0383 --- /dev/null +++ b/.config/nvim/lua/lsp/bash.lua @@ -0,0 +1,2 @@ +-- npm i -g bash-language-server +require'lspconfig'.bashls.setup{} diff --git a/.config/nvim/lua/lsp/docker.lua b/.config/nvim/lua/lsp/docker.lua new file mode 100644 index 0000000..ad6e220 --- /dev/null +++ b/.config/nvim/lua/lsp/docker.lua @@ -0,0 +1,2 @@ +-- npm install -g dockerfile-language-server-nodejs +require'lspconfig'.dockerls.setup{} diff --git a/.config/nvim/lua/lsp/general.lua b/.config/nvim/lua/lsp/general.lua new file mode 100644 index 0000000..fa28dbc --- /dev/null +++ b/.config/nvim/lua/lsp/general.lua @@ -0,0 +1,15 @@ +require"lspconfig".efm.setup { + init_options = {documentFormatting = true}, + filetypes = {"lua"}, + settings = { + rootMarkers = {".git/"}, + languages = { + lua = { + { + formatCommand = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb", + formatStdin = true + } + } + } + } +} diff --git a/.config/nvim/lua/lsp/json.lua b/.config/nvim/lua/lsp/json.lua new file mode 100644 index 0000000..d13fed3 --- /dev/null +++ b/.config/nvim/lua/lsp/json.lua @@ -0,0 +1,10 @@ +-- npm install -g vscode-json-languageserver +require'lspconfig'.jsonls.setup { + commands = { + Format = { + function() + vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0}) + end + } + } +} diff --git a/.config/nvim/lua/lsp/lsp-config.lua b/.config/nvim/lua/lsp/lsp-config.lua new file mode 100644 index 0000000..fe5dfb7 --- /dev/null +++ b/.config/nvim/lua/lsp/lsp-config.lua @@ -0,0 +1,4 @@ +vim.fn.sign_define("LspDiagnosticsSignError", {text = "", numhl = "LspDiagnosticsDefaultError"}) +vim.fn.sign_define("LspDiagnosticsSignWarning", {text = "", numhl = "LspDiagnosticsDefaultWarning"}) +vim.fn.sign_define("LspDiagnosticsSignInformation", {text = "", numhl = "LspDiagnosticsDefaultInformation"}) +vim.fn.sign_define("LspDiagnosticsSignHint", {text = "", numhl = "LspDiagnosticsDefaultHint"}) diff --git a/.config/nvim/lua/lsp/lsp-kind.lua b/.config/nvim/lua/lsp/lsp-kind.lua new file mode 100644 index 0000000..de928c2 --- /dev/null +++ b/.config/nvim/lua/lsp/lsp-kind.lua @@ -0,0 +1,26 @@ +-- commented options are defaults +require('lspkind').init({ + with_text = false, + symbol_map = { + Text = '  ', + Method = '  ', + Function = '  ', + Constructor = '  ', + Variable = '[]', + Class = '  ', + Interface = ' 蘒', + Module = '  ', + Property = '  ', + Unit = ' 塞 ', + Value = '  ', + Enum = ' 練', + Keyword = '  ', + Snippet = '  ', + Color = '', + File = '', + Folder = ' ﱮ ', + EnumMember = '  ', + Constant = '  ', + Struct = '  ' + }, +}) diff --git a/.config/nvim/lua/lsp/lua.lua b/.config/nvim/lua/lsp/lua.lua new file mode 100644 index 0000000..c04219a --- /dev/null +++ b/.config/nvim/lua/lsp/lua.lua @@ -0,0 +1,37 @@ +-- 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/lua-language-server" + sumneko_binary = "/Users/" .. USER .. "/.config/nvim/lua-language-server/bin/macOS/lua-language-server" +elseif vim.fn.has("unix") == 1 then + sumneko_root_path = "/home/" .. USER .. "/.config/nvim/lua-language-server" + sumneko_binary = "/home/" .. USER .. "/.config/nvim/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"}, + 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.lua b/.config/nvim/lua/lsp/python.lua new file mode 100644 index 0000000..11eeef9 --- /dev/null +++ b/.config/nvim/lua/lsp/python.lua @@ -0,0 +1,2 @@ +-- npm i -g pyright +require'lspconfig'.pyright.setup{} diff --git a/.config/nvim/lua/lsp/vim.lua b/.config/nvim/lua/lsp/vim.lua new file mode 100644 index 0000000..a7555c6 --- /dev/null +++ b/.config/nvim/lua/lsp/vim.lua @@ -0,0 +1,2 @@ +-- npm install -g vim-language-server +require'lspconfig'.vimls.setup{} diff --git a/.config/nvim/lua/lsp/wrapper.lua b/.config/nvim/lua/lsp/wrapper.lua new file mode 100644 index 0000000..7f3647c --- /dev/null +++ b/.config/nvim/lua/lsp/wrapper.lua @@ -0,0 +1,129 @@ +local lsp_wrapper = {} + +-- buf + +function lsp_wrapper.add_to_workspace_folder() + vim.lsp.buf.add_workspace_folder() +end + +function lsp_wrapper.clear_references() + vim.lsp.buf.clear_references() +end + +function lsp_wrapper.code_action() + vim.lsp.buf.code_action() +end + +function lsp_wrapper.declaration() + vim.lsp.buf.declaration() + vim.lsp.buf.clear_references() +end + +function lsp_wrapper.definition() + vim.lsp.buf.definition() + vim.lsp.buf.clear_references() +end + +function lsp_wrapper.document_highlight() + vim.lsp.buf.document_highlight() +end + +function lsp_wrapper.document_symbol() + vim.lsp.buf.document_symbol() +end + +function lsp_wrapper.formatting() + vim.lsp.buf.formatting() +end + +function lsp_wrapper.formatting_sync() + vim.lsp.buf.formatting_sync() +end + +function lsp_wrapper.hover() + vim.lsp.buf.hover() +end + +function lsp_wrapper.implementation() + vim.lsp.buf.implementation() +end + +function lsp_wrapper.incoming_calls() + vim.lsp.buf.incoming_calls() +end + +function lsp_wrapper.list_workspace_folders() + vim.lsp.buf.list_workspace_folders() +end + +function lsp_wrapper.outgoing_calls() + vim.lsp.buf.outgoing_calls() +end + +function lsp_wrapper.range_code_action() + vim.lsp.buf.range_code_action() +end + +function lsp_wrapper.range_formatting() + vim.lsp.buf.range_formatting() +end + +function lsp_wrapper.references() + vim.lsp.buf.references() + vim.lsp.buf.clear_references() +end + +function lsp_wrapper.remove_workspace_folder() + vim.lsp.buf.remove_workspace_folder() +end + +function lsp_wrapper.rename() + vim.lsp.buf.rename() +end + +function lsp_wrapper.signature_help() + vim.lsp.buf.signature_help() +end + +function lsp_wrapper.type_definition() + vim.lsp.buf.type_definition() +end + +function lsp_wrapper.workspace_symbol() + vim.lsp.buf.workspace_symbol() +end + +-- diagnostic + +function lsp_wrapper.get_all() + vim.lsp.diagnostic.get_all() +end + +function lsp_wrapper.get_next() + vim.lsp.diagnostic.get_next() +end + +function lsp_wrapper.get_prev() + vim.lsp.diagnostic.get_prev() +end + +function lsp_wrapper.goto_next() + vim.lsp.diagnostic.goto_next() +end + +function lsp_wrapper.goto_prev() + vim.lsp.diagnostic.goto_prev() +end + +function lsp_wrapper.show_line_diagnostics() + vim.lsp.diagnostic.show_line_diagnostics() +end + +-- misc + +-- :lua print(vim.inspect(vim.lsp.buf_get_clients())) + +-- autoformat +-- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000) + +return lsp_wrapper diff --git a/.config/nvim/lua/lsp/yaml.lua b/.config/nvim/lua/lsp/yaml.lua new file mode 100644 index 0000000..904f20e --- /dev/null +++ b/.config/nvim/lua/lsp/yaml.lua @@ -0,0 +1,2 @@ +-- npm install -g yaml-language-server +require'lspconfig'.yamlls.setup{} diff --git a/.config/nvim/lua/nvimtree/init.lua b/.config/nvim/lua/nvimtree/init.lua new file mode 100644 index 0000000..3803765 --- /dev/null +++ b/.config/nvim/lua/nvimtree/init.lua @@ -0,0 +1,31 @@ +local tree_cb = require'nvim-tree.config'.nvim_tree_callback +vim.g.nvim_tree_bindings = { + -- mappings + [""] = tree_cb("edit"), + ["l"] = tree_cb("edit"), + ["o"] = tree_cb("edit"), + ["<2-LeftMouse>"] = tree_cb("edit"), + ["<2-RightMouse>"] = tree_cb("cd"), + [""] = tree_cb("cd"), + ["v"] = tree_cb("vsplit"), + ["s"] = tree_cb("split"), + [""] = tree_cb("tabnew"), + ["h"] = tree_cb("close_node"), + [""] = tree_cb("close_node"), + [""] = tree_cb("close_node"), + [""] = 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"), + [""] = 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") +} diff --git a/.config/nvim/lua/plug-colorizer.lua b/.config/nvim/lua/plug-colorizer.lua deleted file mode 100644 index 1e25d7d..0000000 --- a/.config/nvim/lua/plug-colorizer.lua +++ /dev/null @@ -1,13 +0,0 @@ -require'colorizer'.setup( - {'*';}, - { - RGB = true; -- #RGB hex codes - RRGGBB = true; -- #RRGGBB hex codes - names = true; -- "Name" codes like Blue - 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 - }) - diff --git a/.config/nvim/lua/statusline.lua b/.config/nvim/lua/statusline.lua deleted file mode 100644 index 44801cf..0000000 --- a/.config/nvim/lua/statusline.lua +++ /dev/null @@ -1,233 +0,0 @@ -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 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} - } -} diff --git a/.config/nvim/lua/treesitter.lua b/.config/nvim/lua/treesitter.lua deleted file mode 100644 index d202a9f..0000000 --- a/.config/nvim/lua/treesitter.lua +++ /dev/null @@ -1,15 +0,0 @@ -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 - }, -} - -require "nvim-treesitter.configs".setup { - 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 - } -} diff --git a/.config/nvim/lua/treesitter/init.lua b/.config/nvim/lua/treesitter/init.lua new file mode 100644 index 0000000..d202a9f --- /dev/null +++ b/.config/nvim/lua/treesitter/init.lua @@ -0,0 +1,15 @@ +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 + }, +} + +require "nvim-treesitter.configs".setup { + 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 + } +} -- cgit v1.2.3-70-g09d2