From 99630ae8233f8a2afb6a89016b24a354b0186a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 23 Nov 2022 15:38:16 +0100 Subject: plugins -> subdir core --- init.lua | 1 + lua/user/autopairs.lua | 34 ------ lua/user/bufferline.lua | 170 ----------------------------- lua/user/cmp.lua | 133 ---------------------- lua/user/comment.lua | 24 ---- lua/user/core/autopairs.lua | 34 ++++++ lua/user/core/bufferline.lua | 170 +++++++++++++++++++++++++++++ lua/user/core/cmp.lua | 133 ++++++++++++++++++++++ lua/user/core/comment.lua | 24 ++++ lua/user/core/gitsigns.lua | 49 +++++++++ lua/user/core/init.lua | 9 ++ lua/user/core/lsp/handlers.lua | 94 ++++++++++++++++ lua/user/core/lsp/init.lua | 3 + lua/user/core/lsp/mason.lua | 63 +++++++++++ lua/user/core/lsp/null-ls.lua | 20 ++++ lua/user/core/lsp/settings/sumneko_lua.lua | 16 +++ lua/user/core/nvim-tree.lua | 112 +++++++++++++++++++ lua/user/core/telescope.lua | 97 ++++++++++++++++ lua/user/core/treesitter.lua | 30 +++++ lua/user/gitsigns.lua | 49 --------- lua/user/init.lua | 12 +- lua/user/lsp/handlers.lua | 94 ---------------- lua/user/lsp/init.lua | 3 - lua/user/lsp/mason.lua | 63 ----------- lua/user/lsp/null-ls.lua | 20 ---- lua/user/lsp/settings/sumneko_lua.lua | 16 --- lua/user/nvim-tree.lua | 112 ------------------- lua/user/plugins.lua | 2 +- lua/user/telescope.lua | 97 ---------------- lua/user/treesitter.lua | 30 ----- 30 files changed, 858 insertions(+), 856 deletions(-) delete mode 100644 lua/user/autopairs.lua delete mode 100644 lua/user/bufferline.lua delete mode 100644 lua/user/cmp.lua delete mode 100644 lua/user/comment.lua create mode 100644 lua/user/core/autopairs.lua create mode 100644 lua/user/core/bufferline.lua create mode 100644 lua/user/core/cmp.lua create mode 100644 lua/user/core/comment.lua create mode 100644 lua/user/core/gitsigns.lua create mode 100644 lua/user/core/init.lua create mode 100644 lua/user/core/lsp/handlers.lua create mode 100644 lua/user/core/lsp/init.lua create mode 100644 lua/user/core/lsp/mason.lua create mode 100644 lua/user/core/lsp/null-ls.lua create mode 100644 lua/user/core/lsp/settings/sumneko_lua.lua create mode 100644 lua/user/core/nvim-tree.lua create mode 100644 lua/user/core/telescope.lua create mode 100644 lua/user/core/treesitter.lua delete mode 100644 lua/user/gitsigns.lua delete mode 100644 lua/user/lsp/handlers.lua delete mode 100644 lua/user/lsp/init.lua delete mode 100644 lua/user/lsp/mason.lua delete mode 100644 lua/user/lsp/null-ls.lua delete mode 100644 lua/user/lsp/settings/sumneko_lua.lua delete mode 100644 lua/user/nvim-tree.lua delete mode 100644 lua/user/telescope.lua delete mode 100644 lua/user/treesitter.lua diff --git a/init.lua b/init.lua index 2a8e1cc..3dc16af 100644 --- a/init.lua +++ b/init.lua @@ -12,6 +12,7 @@ vim.cmd[[ \ endif ]] +-- add debounce timer to cmp vim.cmd([[ augroup CmpDebounceAuGroup au! diff --git a/lua/user/autopairs.lua b/lua/user/autopairs.lua deleted file mode 100644 index 96be89e..0000000 --- a/lua/user/autopairs.lua +++ /dev/null @@ -1,34 +0,0 @@ --- Setup nvim-cmp. -local status_ok, npairs = pcall(require, "nvim-autopairs") -if not status_ok then - print "nvim-autopairs init failed" - return -end - -npairs.setup { - check_ts = true, - ts_config = { - lua = { "string", "source" }, - javascript = { "string", "template_string" }, - java = false, - }, - disable_filetype = { "TelescopePrompt", "spectre_panel" }, - fast_wrap = { - map = "", - chars = { "{", "[", "(", '"', "'" }, - pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), - offset = 0, -- Offset from pattern match - end_key = "$", - keys = "qwertyuiopzxcvbnmasdfghjkl", - check_comma = true, - highlight = "PmenuSel", - highlight_grey = "LineNr", - }, -} - -local cmp_autopairs = require "nvim-autopairs.completion.cmp" -local cmp_status_ok, cmp = pcall(require, "cmp") -if not cmp_status_ok then - return -end -cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) diff --git a/lua/user/bufferline.lua b/lua/user/bufferline.lua deleted file mode 100644 index 92ab513..0000000 --- a/lua/user/bufferline.lua +++ /dev/null @@ -1,170 +0,0 @@ -local status_ok, bufferline = pcall(require, "bufferline") -if not status_ok then - print "bufferline init failed" - return -end - -bufferline.setup { - options = { - numbers = "ordinal", -- "none" | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, - close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" - right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" - left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" - middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" - -- NOTE: this plugin is designed with this icon in mind, - -- and so changing this is NOT recommended, this is intended - -- as an escape hatch for people who cannot bear it for whatever reason - indicator = { - style = 'icon', - icon = "▎", - }, - buffer_close_icon = "", - -- buffer_close_icon = '', - modified_icon = "●", - close_icon = "", - -- close_icon = '', - left_trunc_marker = "", - right_trunc_marker = "", - --- name_formatter can be used to change the buffer's label in the bufferline. - --- Please note some names can/will break the - --- bufferline so use this at your discretion knowing that it has - --- some limitations that will *NOT* be fixed. - -- name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" - -- -- remove extension from markdown files for example - -- if buf.name:match('%.md') then - -- return vim.fn.fnamemodify(buf.name, ':t:r') - -- end - -- end, - max_name_length = 30, - max_prefix_length = 30, -- prefix used when a buffer is de-duplicated - tab_size = 21, - diagnostics = true, -- | "nvim_lsp" | "coc", - diagnostics_update_in_insert = false, - -- diagnostics_indicator = function(count, level, diagnostics_dict, context) - -- return "("..count..")" - -- end, - -- NOTE: this will be called a lot so don't do any heavy processing here - -- custom_filter = function(buf_number) - -- -- filter out filetypes you don't want to see - -- if vim.bo[buf_number].filetype ~= "" then - -- return true - -- end - -- -- filter out by buffer name - -- if vim.fn.bufname(buf_number) ~= "" then - -- return true - -- end - -- -- filter out based on arbitrary rules - -- -- e.g. filter out vim wiki buffer from tabline in your work repo - -- if vim.fn.getcwd() == "" and vim.bo[buf_number].filetype ~= "wiki" then - -- return true - -- end - -- end, - offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, - show_buffer_icons = true, - show_buffer_close_icons = true, - show_close_icon = 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", -- | "thick" | "thin" | { 'any', 'any' }, - enforce_regular_tabs = true, - always_show_bufferline = true, - -- sort_by = 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b) - -- -- add custom logic - -- return buffer_a.modified > buffer_b.modified - -- end - }, - highlights = { - fill = { - fg = { attribute = "fg", highlight = "#ff0000" }, - bg = { attribute = "bg", highlight = "TabLine" }, - }, - background = { - fg = { attribute = "fg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - }, - - buffer_selected = { - fg = {attribute='fg',highlight='#ff0000'}, - bg = "#707070", --{attribute='bg',highlight='#0000ff'}, - }, - buffer_visible = { - fg = { attribute = "fg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - }, - - close_button = { - fg = { attribute = "fg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - }, - close_button_visible = { - fg = { attribute = "fg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - }, - -- close_button_selected = { - -- fg = {attribute='fg',highlight='TabLineSel'}, - -- bg ={attribute='bg',highlight='TabLineSel'} - -- }, - - tab_selected = { - fg = { attribute = "fg", highlight = "Normal" }, - bg = { attribute = "bg", highlight = "Normal" }, - }, - tab = { - fg = { attribute = "fg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - }, - tab_close = { - -- fg = {attribute='fg',highlight='LspDiagnosticsDefaultError'}, - fg = { attribute = "fg", highlight = "TabLineSel" }, - bg = { attribute = "bg", highlight = "Normal" }, - }, - - duplicate_selected = { - fg = { attribute = "fg", highlight = "TabLineSel" }, - bg = { attribute = "bg", highlight = "TabLineSel" }, - italic = true, - }, - duplicate_visible = { - fg = { attribute = "fg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - italic = true, - }, - duplicate = { - fg = { attribute = "fg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - italic = true, - }, - - modified = { - fg = { attribute = "fg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - }, - modified_selected = { - fg = { attribute = "fg", highlight = "Normal" }, - bg = { attribute = "bg", highlight = "Normal" }, - }, - modified_visible = { - fg = { attribute = "fg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - }, - - separator = { - fg = { attribute = "bg", highlight = "TabLine" }, - bg = { attribute = "bg", highlight = "TabLine" }, - }, - separator_selected = { - fg = { attribute = "bg", highlight = "Normal" }, - bg = { attribute = "bg", highlight = "Normal" }, - }, - -- separator_visible = { - -- fg = {attribute='bg',highlight='TabLine'}, - -- bg = {attribute='bg',highlight='TabLine'} - -- }, - indicator_selected = { - fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" }, - bg = { attribute = "bg", highlight = "Normal" }, - }, - }, -} diff --git a/lua/user/cmp.lua b/lua/user/cmp.lua deleted file mode 100644 index ff6a97e..0000000 --- a/lua/user/cmp.lua +++ /dev/null @@ -1,133 +0,0 @@ -local cmp_status_ok, cmp = pcall(require, "cmp") -if not cmp_status_ok then - print "cmp init failed" - return -end - -local snip_status_ok, luasnip = pcall(require, "luasnip") -if not snip_status_ok then - return -end -require("luasnip/loaders/from_vscode").lazy_load() - -local check_backspace = function() - local col = vim.fn.col "." - 1 - return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" -end - ---   פּ ﯟ   some other good icons -local kind_icons = { - Text = "", - Method = "m", - Function = "", - Constructor = "", - Field = "", - Variable = "", - Class = "", - Interface = "", - Module = "", - Property = "", - Unit = "", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "", -} --- find more here: https://www.nerdfonts.com/cheat-sheet - -cmp.setup { - completion = { - autocomplete = false, -- see init.lua : debounce - }, - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) -- For `luasnip` users. - end, - }, - mapping = { - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. - [""] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }, - -- Accept currently selected item. If none selected, `select` first item. - -- Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping.confirm { select = true }, - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expandable() then - luasnip.expand() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif check_backspace() then - fallback() - else - fallback() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { - "i", - "s", - }), - }, - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - -- Kind icons - vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) - -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind - vim_item.menu = ({ - nvim_lsp = "[LSP]", - luasnip = "[Snippet]", - buffer = "[Buffer]", - path = "[Path]", - })[entry.source.name] - return vim_item - end, - }, - -- SEE : https://github.com/hrsh7th/nvim-cmp#where-can-i-find-more-completion-sources - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - }, - confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - window = { - documentation = "native", - }, - experimental = { - ghost_text = true, -- grey autosuggestion - native_menu = false, - }, -} diff --git a/lua/user/comment.lua b/lua/user/comment.lua deleted file mode 100644 index 7d36862..0000000 --- a/lua/user/comment.lua +++ /dev/null @@ -1,24 +0,0 @@ -local status_ok, comment = pcall(require, "Comment") -if not status_ok then - print "Comment init failed" - return -end - -comment.setup { - pre_hook = function(ctx) - local U = require "Comment.utils" - - local location = nil - if ctx.ctype == U.ctype.block then - location = require("ts_context_commentstring.utils").get_cursor_location() - elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then - location = require("ts_context_commentstring.utils").get_visual_start_location() - end - - return require("ts_context_commentstring.internal").calculate_commentstring { - key = ctx.ctype == U.ctype.line and "__default" or "__multiline", - location = location, - } - end, -} - diff --git a/lua/user/core/autopairs.lua b/lua/user/core/autopairs.lua new file mode 100644 index 0000000..96be89e --- /dev/null +++ b/lua/user/core/autopairs.lua @@ -0,0 +1,34 @@ +-- Setup nvim-cmp. +local status_ok, npairs = pcall(require, "nvim-autopairs") +if not status_ok then + print "nvim-autopairs init failed" + return +end + +npairs.setup { + check_ts = true, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + fast_wrap = { + map = "", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, +} + +local cmp_autopairs = require "nvim-autopairs.completion.cmp" +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) diff --git a/lua/user/core/bufferline.lua b/lua/user/core/bufferline.lua new file mode 100644 index 0000000..92ab513 --- /dev/null +++ b/lua/user/core/bufferline.lua @@ -0,0 +1,170 @@ +local status_ok, bufferline = pcall(require, "bufferline") +if not status_ok then + print "bufferline init failed" + return +end + +bufferline.setup { + options = { + numbers = "ordinal", -- "none" | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, + close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" + -- NOTE: this plugin is designed with this icon in mind, + -- and so changing this is NOT recommended, this is intended + -- as an escape hatch for people who cannot bear it for whatever reason + indicator = { + style = 'icon', + icon = "▎", + }, + buffer_close_icon = "", + -- buffer_close_icon = '', + modified_icon = "●", + close_icon = "", + -- close_icon = '', + left_trunc_marker = "", + right_trunc_marker = "", + --- name_formatter can be used to change the buffer's label in the bufferline. + --- Please note some names can/will break the + --- bufferline so use this at your discretion knowing that it has + --- some limitations that will *NOT* be fixed. + -- name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" + -- -- remove extension from markdown files for example + -- if buf.name:match('%.md') then + -- return vim.fn.fnamemodify(buf.name, ':t:r') + -- end + -- end, + max_name_length = 30, + max_prefix_length = 30, -- prefix used when a buffer is de-duplicated + tab_size = 21, + diagnostics = true, -- | "nvim_lsp" | "coc", + diagnostics_update_in_insert = false, + -- diagnostics_indicator = function(count, level, diagnostics_dict, context) + -- return "("..count..")" + -- end, + -- NOTE: this will be called a lot so don't do any heavy processing here + -- custom_filter = function(buf_number) + -- -- filter out filetypes you don't want to see + -- if vim.bo[buf_number].filetype ~= "" then + -- return true + -- end + -- -- filter out by buffer name + -- if vim.fn.bufname(buf_number) ~= "" then + -- return true + -- end + -- -- filter out based on arbitrary rules + -- -- e.g. filter out vim wiki buffer from tabline in your work repo + -- if vim.fn.getcwd() == "" and vim.bo[buf_number].filetype ~= "wiki" then + -- return true + -- end + -- end, + offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = 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", -- | "thick" | "thin" | { 'any', 'any' }, + enforce_regular_tabs = true, + always_show_bufferline = true, + -- sort_by = 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b) + -- -- add custom logic + -- return buffer_a.modified > buffer_b.modified + -- end + }, + highlights = { + fill = { + fg = { attribute = "fg", highlight = "#ff0000" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + background = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + buffer_selected = { + fg = {attribute='fg',highlight='#ff0000'}, + bg = "#707070", --{attribute='bg',highlight='#0000ff'}, + }, + buffer_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + close_button = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + close_button_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + -- close_button_selected = { + -- fg = {attribute='fg',highlight='TabLineSel'}, + -- bg ={attribute='bg',highlight='TabLineSel'} + -- }, + + tab_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + tab = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + tab_close = { + -- fg = {attribute='fg',highlight='LspDiagnosticsDefaultError'}, + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + + duplicate_selected = { + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "TabLineSel" }, + italic = true, + }, + duplicate_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + italic = true, + }, + duplicate = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + italic = true, + }, + + modified = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + modified_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + modified_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + separator = { + fg = { attribute = "bg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + separator_selected = { + fg = { attribute = "bg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + -- separator_visible = { + -- fg = {attribute='bg',highlight='TabLine'}, + -- bg = {attribute='bg',highlight='TabLine'} + -- }, + indicator_selected = { + fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + }, +} diff --git a/lua/user/core/cmp.lua b/lua/user/core/cmp.lua new file mode 100644 index 0000000..ff6a97e --- /dev/null +++ b/lua/user/core/cmp.lua @@ -0,0 +1,133 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + print "cmp init failed" + return +end + +local snip_status_ok, luasnip = pcall(require, "luasnip") +if not snip_status_ok then + return +end +require("luasnip/loaders/from_vscode").lazy_load() + +local check_backspace = function() + local col = vim.fn.col "." - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" +end + +--   פּ ﯟ   some other good icons +local kind_icons = { + Text = "", + Method = "m", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", +} +-- find more here: https://www.nerdfonts.com/cheat-sheet + +cmp.setup { + completion = { + autocomplete = false, -- see init.lua : debounce + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [""] = cmp.mapping { + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }, + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm { select = true }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + vim_item.menu = ({ + nvim_lsp = "[LSP]", + luasnip = "[Snippet]", + buffer = "[Buffer]", + path = "[Path]", + })[entry.source.name] + return vim_item + end, + }, + -- SEE : https://github.com/hrsh7th/nvim-cmp#where-can-i-find-more-completion-sources + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + documentation = "native", + }, + experimental = { + ghost_text = true, -- grey autosuggestion + native_menu = false, + }, +} diff --git a/lua/user/core/comment.lua b/lua/user/core/comment.lua new file mode 100644 index 0000000..7d36862 --- /dev/null +++ b/lua/user/core/comment.lua @@ -0,0 +1,24 @@ +local status_ok, comment = pcall(require, "Comment") +if not status_ok then + print "Comment init failed" + return +end + +comment.setup { + pre_hook = function(ctx) + local U = require "Comment.utils" + + local location = nil + if ctx.ctype == U.ctype.block then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require("ts_context_commentstring.utils").get_visual_start_location() + end + + return require("ts_context_commentstring.internal").calculate_commentstring { + key = ctx.ctype == U.ctype.line and "__default" or "__multiline", + location = location, + } + end, +} + diff --git a/lua/user/core/gitsigns.lua b/lua/user/core/gitsigns.lua new file mode 100644 index 0000000..ca88cdf --- /dev/null +++ b/lua/user/core/gitsigns.lua @@ -0,0 +1,49 @@ +local status_ok, gitsigns = pcall(require, "gitsigns") +if not status_ok then + print "gitsigns init failed" + return +end + +gitsigns.setup { + signs = { + 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" }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter_opts = { + relative_time = false, + }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + yadm = { + enable = false, + }, +} diff --git a/lua/user/core/init.lua b/lua/user/core/init.lua new file mode 100644 index 0000000..64d8e28 --- /dev/null +++ b/lua/user/core/init.lua @@ -0,0 +1,9 @@ +require 'user.core.autopairs' +require 'user.core.bufferline' +require 'user.core.cmp' +require 'user.core.comment' +require 'user.core.telescope' +require 'user.core.treesitter' +require 'user.core.gitsigns' +require 'user.core.nvim-tree' +require 'user.core.lsp' diff --git a/lua/user/core/lsp/handlers.lua b/lua/user/core/lsp/handlers.lua new file mode 100644 index 0000000..853beb3 --- /dev/null +++ b/lua/user/core/lsp/handlers.lua @@ -0,0 +1,94 @@ +local M = {} + +local cmp_nvim_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not cmp_nvim_ok then + print "cpm_nvim_lsp init failed" + return +end + +M.setup = function() + local signs = { Error = "", Warn = "", Hint = "", Info = "" } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end + + local config = { + -- disable virtual text + virtual_text = false, + -- show signs + signs = { + active = signs, + }, + update_in_insert = false, + underline = true, + severity_sort = true, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +local function lsp_highlight(client) + -- Set autocommands conditional on server_capabilities + if client.server_capabilities.document_highlight then + vim.api.nvim_exec( + [[ + 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 keymap = vim.keymap.set + +local function lsp_keymaps(bufnr) + local opts = { buffer = bufnr, noremap = true, silent = true } + -- SEE : https://neovim.io/doc/user/lsp.html + keymap("n", "gd", vim.lsp.buf.definition, opts) + keymap("n", "gr", vim.lsp.buf.references, opts) + keymap("n", "gi", vim.lsp.buf.implementation, opts) + keymap("n", "ga", vim.lsp.buf.declaration, opts) + + keymap("n", "gb", vim.lsp.buf.hover, opts) + keymap("n", "gé", vim.lsp.buf.signature_help, opts) + keymap("n", "gk", vim.diagnostic.open_float, opts) + keymap("n", "g.", vim.diagnostic.goto_next, opts) + keymap("n", "gx", vim.diagnostic.goto_prev, opts) + keymap("n", "q", vim.diagnostic.setloclist, opts) + vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] -- FIXME what ? +end + +M.on_attach = function(client, bufnr) + if client.name == "tsserver" then + client.server_capabilities.document_formatting = false + end + lsp_keymaps(bufnr) + lsp_highlight(client) +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() + +M.capabilities = cmp_nvim_lsp.default_capabilities(capabilities) + +return M diff --git a/lua/user/core/lsp/init.lua b/lua/user/core/lsp/init.lua new file mode 100644 index 0000000..a95a5ca --- /dev/null +++ b/lua/user/core/lsp/init.lua @@ -0,0 +1,3 @@ +require 'user.core.lsp.mason' +require('user.core.lsp.handlers').setup() +require 'user.core.lsp.null-ls' diff --git a/lua/user/core/lsp/mason.lua b/lua/user/core/lsp/mason.lua new file mode 100644 index 0000000..9708ec8 --- /dev/null +++ b/lua/user/core/lsp/mason.lua @@ -0,0 +1,63 @@ +local mason_ok, mason = pcall(require, "mason") +if not mason_ok then + print "mason init failed" + return +end + +local mason_lspconfig_ok, mason_lspconfig = pcall(require, "mason-lspconfig") +if not mason_lspconfig_ok then + print "mason-lspconfig init failed" + return +end + +local lspconfig_ok, lspconfig = pcall(require, "lspconfig") +if not lspconfig_ok then + print "lspconfig init failed" + return +end + +require('lspconfig.ui.windows').default_options.border = 'rounded' + +local servers = { + "clangd", + "jdtls", + "jsonls", + "ltex", + "rust_analyzer", + "solargraph", + "sumneko_lua", +} + +mason.setup({ + ui = { + border = "single", + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } +}) + +mason_lspconfig.setup({ + ensure_installed = servers, +}) + +mason_lspconfig.setup_handlers({ + function(server_name) + local opts = { + on_attach = require("user.core.lsp.handlers").on_attach, + capabilities = require("user.core.lsp.handlers").capabilities, + falgs = { + debounce_text_changes = 5000, + }, + } + + local require_ok, server = pcall(require, "user.core.lsp.settings." .. server_name) + if require_ok then + opts = vim.tbl_deep_extend("force", server, opts) + end + + lspconfig[server_name].setup(opts) + end, +}) diff --git a/lua/user/core/lsp/null-ls.lua b/lua/user/core/lsp/null-ls.lua new file mode 100644 index 0000000..389e68f --- /dev/null +++ b/lua/user/core/lsp/null-ls.lua @@ -0,0 +1,20 @@ +local null_ls_ok, null_ls = pcall(require, "null-ls") +if not null_ls_ok then + print "null-ls init failed" + return +end + +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting +local formatting = null_ls.builtins.formatting +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics +local diagnostics = null_ls.builtins.diagnostics + +null_ls.setup({ + debug = false, + sources = { + formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), + formatting.black.with({ extra_args = { "--fast" } }), + formatting.stylua, + -- diagnostics.flake8 + }, +}) diff --git a/lua/user/core/lsp/settings/sumneko_lua.lua b/lua/user/core/lsp/settings/sumneko_lua.lua new file mode 100644 index 0000000..d7e82b4 --- /dev/null +++ b/lua/user/core/lsp/settings/sumneko_lua.lua @@ -0,0 +1,16 @@ +return { + settings = { + + Lua = { + diagnostics = { + globals = { "vim" }, -- teach about vim global variable + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, +} diff --git a/lua/user/core/nvim-tree.lua b/lua/user/core/nvim-tree.lua new file mode 100644 index 0000000..d94da10 --- /dev/null +++ b/lua/user/core/nvim-tree.lua @@ -0,0 +1,112 @@ +-- following options are the default +-- each of these are documented in `:help nvim-tree.OPTION_NAME` + +local status_ok, nvim_tree = pcall(require, "nvim-tree") +if not status_ok then + return +end + +local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +if not config_status_ok then + return +end + +local tree_cb = nvim_tree_config.nvim_tree_callback + +nvim_tree.setup { + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = { }, + open_on_tab = false, + hijack_cursor = false, + update_cwd = true, + -- update_to_buf_dir = { + -- enable = true, + -- auto_open = true, + -- }, + renderer = { + icons = { + glyphs = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + deleted = "", + untracked = "U", + ignored = "◌", + }, + folder = { + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + }, + }, + }, + }, + diagnostics = { + enable = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + update_focused_file = { + enable = true, + update_cwd = true, + ignore_list = {}, + }, + system_open = { + cmd = nil, + args = {}, + }, + filters = { + dotfiles = false, + custom = {}, + }, + git = { + enable = true, + ignore = true, + timeout = 500, + }, + view = { + width = 30, + hide_root_folder = false, + side = "left", + -- auto_resize = true, + mappings = { + custom_only = false, + list = { -- see https://github.com/kyazdani42/nvim-tree.lua#keybindings + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "t", action = "next_sibling"}, + { key = "s", action = "prev_sibling"}, + { key = ">", action = "next_git_item"}, + { key = "<", action = "prev_git_item"}, + }, + }, + number = false, + relativenumber = false, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + -- quit_on_open = 0, + -- git_hl = 1, + -- disable_window_picker = 0, + -- root_folder_modifier = ":t", + -- show_icons = { + -- git = 1, + -- folders = 1, + -- files = 1, + -- folder_arrows = 1, + -- tree_width = 30, + -- }, +} diff --git a/lua/user/core/telescope.lua b/lua/user/core/telescope.lua new file mode 100644 index 0000000..86d1e51 --- /dev/null +++ b/lua/user/core/telescope.lua @@ -0,0 +1,97 @@ +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + print "telescope init failed" + return +end + +local actions = require "telescope.actions" + +telescope.setup { + defaults = { + + prompt_prefix = " ", + selection_caret = " ", + path_display = { "smart" }, + + mappings = { + i = { + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + + [""] = actions.close, + + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + + [""] = actions.select_default, + [""] = actions.select_horizontal, + [""] = actions.select_vertical, + [""] = actions.select_tab, + + [""] = actions.preview_scrolling_up, + [""] = actions.preview_scrolling_down, + + [""] = actions.results_scrolling_up, + [""] = actions.results_scrolling_down, + + [""] = actions.toggle_selection + actions.move_selection_worse, + [""] = actions.toggle_selection + actions.move_selection_better, + [""] = actions.send_to_qflist + actions.open_qflist, + [""] = actions.send_selected_to_qflist + actions.open_qflist, + [""] = actions.complete_tag, + [""] = actions.which_key, -- keys from pressing + }, + + n = { + [""] = actions.close, + [""] = actions.select_default, + [""] = actions.select_horizontal, + [""] = actions.select_vertical, + [""] = actions.select_tab, + + [""] = actions.toggle_selection + actions.move_selection_worse, + [""] = actions.toggle_selection + actions.move_selection_better, + [""] = actions.send_to_qflist + actions.open_qflist, + [""] = actions.send_selected_to_qflist + actions.open_qflist, + + ["j"] = actions.move_selection_next, + ["k"] = actions.move_selection_previous, + ["H"] = actions.move_to_top, + ["M"] = actions.move_to_middle, + ["L"] = actions.move_to_bottom, + + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + ["gg"] = actions.move_to_top, + ["G"] = actions.move_to_bottom, + + [""] = actions.preview_scrolling_up, + [""] = actions.preview_scrolling_down, + + [""] = actions.results_scrolling_up, + [""] = actions.results_scrolling_down, + + ["?"] = actions.which_key, + }, + }, + }, + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + }, + extensions = { + -- Your extension configuration goes here: + -- extension_name = { + -- extension_config_key = value, + -- } + -- please take a look at the readme of the extension you want to configure + }, +} diff --git a/lua/user/core/treesitter.lua b/lua/user/core/treesitter.lua new file mode 100644 index 0000000..05d8fbf --- /dev/null +++ b/lua/user/core/treesitter.lua @@ -0,0 +1,30 @@ +local status_ok, configs = pcall(require, "nvim-treesitter.configs") +if not status_ok then + print "nvim-treesitter.configs init failed" + return +end + +configs.setup { + ensure_installed = {"ruby"}, -- one of "all" or a list of languages + sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) + ignore_install = { "" }, -- List of parsers to ignore installing + autopairs = { + enable = true, + }, + highlight = { + enable = true, -- false will disable the whole extension + disable = { "" }, -- list of language that will be disabled + additional_vim_regex_highlighting = true, + }, + indent = { enable = true, disable = { "yaml" } }, + context_commentstring = { -- for nvim-ts-context-commentstring + enable = true, + enable_autocmd = false, + }, + playground = { + enable = true, + }, + rainbow = { + enable = true, + } +} diff --git a/lua/user/gitsigns.lua b/lua/user/gitsigns.lua deleted file mode 100644 index ca88cdf..0000000 --- a/lua/user/gitsigns.lua +++ /dev/null @@ -1,49 +0,0 @@ -local status_ok, gitsigns = pcall(require, "gitsigns") -if not status_ok then - print "gitsigns init failed" - return -end - -gitsigns.setup { - signs = { - 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" }, - }, - signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = false, -- Toggle with `:Gitsigns toggle_numhl` - linehl = false, -- Toggle with `:Gitsigns toggle_linehl` - word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` - watch_gitdir = { - interval = 1000, - follow_files = true, - }, - attach_to_untracked = true, - current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' - delay = 1000, - ignore_whitespace = false, - }, - current_line_blame_formatter_opts = { - relative_time = false, - }, - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - max_file_length = 40000, - preview_config = { - -- Options passed to nvim_open_win - border = "single", - style = "minimal", - relative = "cursor", - row = 0, - col = 1, - }, - yadm = { - enable = false, - }, -} diff --git a/lua/user/init.lua b/lua/user/init.lua index 12b3873..161a34b 100644 --- a/lua/user/init.lua +++ b/lua/user/init.lua @@ -1,14 +1,6 @@ +require 'user.plugins' require 'user.options' require 'user.bepo' require 'user.keymaps' -require 'user.plugins' require 'user.colorscheme' -require 'user.cmp' -require 'user.lsp' -require 'user.comment' -require 'user.telescope' -require 'user.treesitter' -require 'user.autopairs' -require 'user.gitsigns' -require 'user.nvim-tree' -require 'user.bufferline' +require 'user.core' diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua deleted file mode 100644 index 853beb3..0000000 --- a/lua/user/lsp/handlers.lua +++ /dev/null @@ -1,94 +0,0 @@ -local M = {} - -local cmp_nvim_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") -if not cmp_nvim_ok then - print "cpm_nvim_lsp init failed" - return -end - -M.setup = function() - local signs = { Error = "", Warn = "", Hint = "", Info = "" } - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) - end - - local config = { - -- disable virtual text - virtual_text = false, - -- show signs - signs = { - active = signs, - }, - update_in_insert = false, - underline = true, - severity_sort = true, - float = { - focusable = false, - style = "minimal", - border = "rounded", - source = "always", - header = "", - prefix = "", - }, - } - - vim.diagnostic.config(config) - - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = "rounded", - }) - - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = "rounded", - }) -end - -local function lsp_highlight(client) - -- Set autocommands conditional on server_capabilities - if client.server_capabilities.document_highlight then - vim.api.nvim_exec( - [[ - 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 keymap = vim.keymap.set - -local function lsp_keymaps(bufnr) - local opts = { buffer = bufnr, noremap = true, silent = true } - -- SEE : https://neovim.io/doc/user/lsp.html - keymap("n", "gd", vim.lsp.buf.definition, opts) - keymap("n", "gr", vim.lsp.buf.references, opts) - keymap("n", "gi", vim.lsp.buf.implementation, opts) - keymap("n", "ga", vim.lsp.buf.declaration, opts) - - keymap("n", "gb", vim.lsp.buf.hover, opts) - keymap("n", "gé", vim.lsp.buf.signature_help, opts) - keymap("n", "gk", vim.diagnostic.open_float, opts) - keymap("n", "g.", vim.diagnostic.goto_next, opts) - keymap("n", "gx", vim.diagnostic.goto_prev, opts) - keymap("n", "q", vim.diagnostic.setloclist, opts) - vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] -- FIXME what ? -end - -M.on_attach = function(client, bufnr) - if client.name == "tsserver" then - client.server_capabilities.document_formatting = false - end - lsp_keymaps(bufnr) - lsp_highlight(client) -end - -local capabilities = vim.lsp.protocol.make_client_capabilities() - -M.capabilities = cmp_nvim_lsp.default_capabilities(capabilities) - -return M diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua deleted file mode 100644 index 50c423a..0000000 --- a/lua/user/lsp/init.lua +++ /dev/null @@ -1,3 +0,0 @@ -require 'user.lsp.mason' -require('user.lsp.handlers').setup() -require 'user.lsp.null-ls' diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua deleted file mode 100644 index b841d72..0000000 --- a/lua/user/lsp/mason.lua +++ /dev/null @@ -1,63 +0,0 @@ -local mason_ok, mason = pcall(require, "mason") -if not mason_ok then - print "mason init failed" - return -end - -local mason_lspconfig_ok, mason_lspconfig = pcall(require, "mason-lspconfig") -if not mason_lspconfig_ok then - print "mason-lspconfig init failed" - return -end - -local lspconfig_ok, lspconfig = pcall(require, "lspconfig") -if not lspconfig_ok then - print "lspconfig init failed" - return -end - -require('lspconfig.ui.windows').default_options.border = 'rounded' - -local servers = { - "clangd", - "jdtls", - "jsonls", - "ltex", - "rust_analyzer", - "solargraph", - "sumneko_lua", -} - -mason.setup({ - ui = { - border = "single", - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } -}) - -mason_lspconfig.setup({ - ensure_installed = servers, -}) - -mason_lspconfig.setup_handlers({ - function(server_name) - local opts = { - on_attach = require("user.lsp.handlers").on_attach, - capabilities = require("user.lsp.handlers").capabilities, - falgs = { - debounce_text_changes = 5000, - }, - } - - local require_ok, server = pcall(require, "user.lsp.settings." .. server_name) - if require_ok then - opts = vim.tbl_deep_extend("force", server, opts) - end - - lspconfig[server_name].setup(opts) - end, -}) diff --git a/lua/user/lsp/null-ls.lua b/lua/user/lsp/null-ls.lua deleted file mode 100644 index 389e68f..0000000 --- a/lua/user/lsp/null-ls.lua +++ /dev/null @@ -1,20 +0,0 @@ -local null_ls_ok, null_ls = pcall(require, "null-ls") -if not null_ls_ok then - print "null-ls init failed" - return -end - --- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting -local formatting = null_ls.builtins.formatting --- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics -local diagnostics = null_ls.builtins.diagnostics - -null_ls.setup({ - debug = false, - sources = { - formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), - formatting.black.with({ extra_args = { "--fast" } }), - formatting.stylua, - -- diagnostics.flake8 - }, -}) diff --git a/lua/user/lsp/settings/sumneko_lua.lua b/lua/user/lsp/settings/sumneko_lua.lua deleted file mode 100644 index d7e82b4..0000000 --- a/lua/user/lsp/settings/sumneko_lua.lua +++ /dev/null @@ -1,16 +0,0 @@ -return { - settings = { - - Lua = { - diagnostics = { - globals = { "vim" }, -- teach about vim global variable - }, - workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, - }, - }, - }, - }, -} diff --git a/lua/user/nvim-tree.lua b/lua/user/nvim-tree.lua deleted file mode 100644 index d94da10..0000000 --- a/lua/user/nvim-tree.lua +++ /dev/null @@ -1,112 +0,0 @@ --- following options are the default --- each of these are documented in `:help nvim-tree.OPTION_NAME` - -local status_ok, nvim_tree = pcall(require, "nvim-tree") -if not status_ok then - return -end - -local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") -if not config_status_ok then - return -end - -local tree_cb = nvim_tree_config.nvim_tree_callback - -nvim_tree.setup { - disable_netrw = true, - hijack_netrw = true, - open_on_setup = false, - ignore_ft_on_setup = { }, - open_on_tab = false, - hijack_cursor = false, - update_cwd = true, - -- update_to_buf_dir = { - -- enable = true, - -- auto_open = true, - -- }, - renderer = { - icons = { - glyphs = { - default = "", - symlink = "", - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - deleted = "", - untracked = "U", - ignored = "◌", - }, - folder = { - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - }, - }, - }, - }, - diagnostics = { - enable = true, - icons = { - hint = "", - info = "", - warning = "", - error = "", - }, - }, - update_focused_file = { - enable = true, - update_cwd = true, - ignore_list = {}, - }, - system_open = { - cmd = nil, - args = {}, - }, - filters = { - dotfiles = false, - custom = {}, - }, - git = { - enable = true, - ignore = true, - timeout = 500, - }, - view = { - width = 30, - hide_root_folder = false, - side = "left", - -- auto_resize = true, - mappings = { - custom_only = false, - list = { -- see https://github.com/kyazdani42/nvim-tree.lua#keybindings - { key = { "l", "", "o" }, cb = tree_cb "edit" }, - { key = "t", action = "next_sibling"}, - { key = "s", action = "prev_sibling"}, - { key = ">", action = "next_git_item"}, - { key = "<", action = "prev_git_item"}, - }, - }, - number = false, - relativenumber = false, - }, - trash = { - cmd = "trash", - require_confirm = true, - }, - -- quit_on_open = 0, - -- git_hl = 1, - -- disable_window_picker = 0, - -- root_folder_modifier = ":t", - -- show_icons = { - -- git = 1, - -- folders = 1, - -- files = 1, - -- folder_arrows = 1, - -- tree_width = 30, - -- }, -} diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua index 74d1c55..e8efb4e 100644 --- a/lua/user/plugins.lua +++ b/lua/user/plugins.lua @@ -47,7 +47,7 @@ return packer.startup(function(use) use 'nvim-lua/popup.nvim' -- An implementation of the Popup API from vim in Neovim use 'nvim-lua/plenary.nvim' -- Useful lua functions used in lots of plugins use 'numToStr/Comment.nvim' -- gc[N][motion] - -- use 'windwp/nvim-autopairs' -- Autopairs, integrates with both cmp and treesitter + use 'windwp/nvim-autopairs' -- Autopairs, integrates with both cmp and treesitter use 'kyazdani42/nvim-web-devicons' -- nices icons use 'kyazdani42/nvim-tree.lua' -- tree explorer use 'akinsho/bufferline.nvim' -- buffer status line diff --git a/lua/user/telescope.lua b/lua/user/telescope.lua deleted file mode 100644 index 86d1e51..0000000 --- a/lua/user/telescope.lua +++ /dev/null @@ -1,97 +0,0 @@ -local status_ok, telescope = pcall(require, "telescope") -if not status_ok then - print "telescope init failed" - return -end - -local actions = require "telescope.actions" - -telescope.setup { - defaults = { - - prompt_prefix = " ", - selection_caret = " ", - path_display = { "smart" }, - - mappings = { - i = { - [""] = actions.cycle_history_next, - [""] = actions.cycle_history_prev, - - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - - [""] = actions.close, - - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - - [""] = actions.select_default, - [""] = actions.select_horizontal, - [""] = actions.select_vertical, - [""] = actions.select_tab, - - [""] = actions.preview_scrolling_up, - [""] = actions.preview_scrolling_down, - - [""] = actions.results_scrolling_up, - [""] = actions.results_scrolling_down, - - [""] = actions.toggle_selection + actions.move_selection_worse, - [""] = actions.toggle_selection + actions.move_selection_better, - [""] = actions.send_to_qflist + actions.open_qflist, - [""] = actions.send_selected_to_qflist + actions.open_qflist, - [""] = actions.complete_tag, - [""] = actions.which_key, -- keys from pressing - }, - - n = { - [""] = actions.close, - [""] = actions.select_default, - [""] = actions.select_horizontal, - [""] = actions.select_vertical, - [""] = actions.select_tab, - - [""] = actions.toggle_selection + actions.move_selection_worse, - [""] = actions.toggle_selection + actions.move_selection_better, - [""] = actions.send_to_qflist + actions.open_qflist, - [""] = actions.send_selected_to_qflist + actions.open_qflist, - - ["j"] = actions.move_selection_next, - ["k"] = actions.move_selection_previous, - ["H"] = actions.move_to_top, - ["M"] = actions.move_to_middle, - ["L"] = actions.move_to_bottom, - - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - ["gg"] = actions.move_to_top, - ["G"] = actions.move_to_bottom, - - [""] = actions.preview_scrolling_up, - [""] = actions.preview_scrolling_down, - - [""] = actions.results_scrolling_up, - [""] = actions.results_scrolling_down, - - ["?"] = actions.which_key, - }, - }, - }, - pickers = { - -- Default configuration for builtin pickers goes here: - -- picker_name = { - -- picker_config_key = value, - -- ... - -- } - -- Now the picker_config_key will be applied every time you call this - -- builtin picker - }, - extensions = { - -- Your extension configuration goes here: - -- extension_name = { - -- extension_config_key = value, - -- } - -- please take a look at the readme of the extension you want to configure - }, -} diff --git a/lua/user/treesitter.lua b/lua/user/treesitter.lua deleted file mode 100644 index 05d8fbf..0000000 --- a/lua/user/treesitter.lua +++ /dev/null @@ -1,30 +0,0 @@ -local status_ok, configs = pcall(require, "nvim-treesitter.configs") -if not status_ok then - print "nvim-treesitter.configs init failed" - return -end - -configs.setup { - ensure_installed = {"ruby"}, -- one of "all" or a list of languages - sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) - ignore_install = { "" }, -- List of parsers to ignore installing - autopairs = { - enable = true, - }, - highlight = { - enable = true, -- false will disable the whole extension - disable = { "" }, -- list of language that will be disabled - additional_vim_regex_highlighting = true, - }, - indent = { enable = true, disable = { "yaml" } }, - context_commentstring = { -- for nvim-ts-context-commentstring - enable = true, - enable_autocmd = false, - }, - playground = { - enable = true, - }, - rainbow = { - enable = true, - } -} -- cgit v1.1-2-g2b99