summaryrefslogtreecommitdiffstats
path: root/lua/user/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2022-11-23 15:38:16 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2022-11-23 15:38:16 +0100
commit99630ae8233f8a2afb6a89016b24a354b0186a21 (patch)
tree01ccbb1e8843ce1dbc9383579575dc48eef60f2c /lua/user/core
parent904acb28247999214aefd33a0cd3ddcea99d7dc0 (diff)
downloadvim-99630ae8233f8a2afb6a89016b24a354b0186a21.zip
vim-99630ae8233f8a2afb6a89016b24a354b0186a21.tar.gz
plugins -> subdir core
Diffstat (limited to 'lua/user/core')
-rw-r--r--lua/user/core/autopairs.lua34
-rw-r--r--lua/user/core/bufferline.lua170
-rw-r--r--lua/user/core/cmp.lua133
-rw-r--r--lua/user/core/comment.lua24
-rw-r--r--lua/user/core/gitsigns.lua49
-rw-r--r--lua/user/core/init.lua9
-rw-r--r--lua/user/core/lsp/handlers.lua94
-rw-r--r--lua/user/core/lsp/init.lua3
-rw-r--r--lua/user/core/lsp/mason.lua63
-rw-r--r--lua/user/core/lsp/null-ls.lua20
-rw-r--r--lua/user/core/lsp/settings/sumneko_lua.lua16
-rw-r--r--lua/user/core/nvim-tree.lua112
-rw-r--r--lua/user/core/telescope.lua97
-rw-r--r--lua/user/core/treesitter.lua30
14 files changed, 854 insertions, 0 deletions
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 = "<M-e>",
+ 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 ~= "<i-dont-want-to-see-this>" then
+ -- return true
+ -- end
+ -- -- filter out by buffer name
+ -- if vim.fn.bufname(buf_number) ~= "<buffer-name-I-dont-want>" 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() == "<work-repo>" 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 = {
+ ["<A-s>"] = cmp.mapping.select_prev_item(),
+ ["<A-t>"] = cmp.mapping.select_next_item(),
+ ["<A-c>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
+ ["<A-r>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
+ ["<A-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
+ ["<A-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
+ ["<A-e>"] = 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.
+ ["<CR>"] = cmp.mapping.confirm { select = true },
+ ["<Tab>"] = 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",
+ }),
+ ["<S-Tab>"] = 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! * <buffer>
+ autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
+ autocmd CursorMoved <buffer> 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", "<leader>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", "<CR>", "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 = {
+ ["<C-n>"] = actions.cycle_history_next,
+ ["<C-p>"] = actions.cycle_history_prev,
+
+ ["<C-t>"] = actions.move_selection_next,
+ ["<C-s>"] = actions.move_selection_previous,
+
+ ["<C-c>"] = actions.close,
+
+ ["<Down>"] = actions.move_selection_next,
+ ["<Up>"] = actions.move_selection_previous,
+
+ ["<CR>"] = actions.select_default,
+ ["<C-x>"] = actions.select_horizontal,
+ ["<C-v>"] = actions.select_vertical,
+ ["<C-k>"] = actions.select_tab,
+
+ ["<C-u>"] = actions.preview_scrolling_up,
+ ["<C-d>"] = actions.preview_scrolling_down,
+
+ ["<PageUp>"] = actions.results_scrolling_up,
+ ["<PageDown>"] = actions.results_scrolling_down,
+
+ ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
+ ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
+ ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
+ ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
+ ["<C-l>"] = actions.complete_tag,
+ ["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
+ },
+
+ n = {
+ ["<esc>"] = actions.close,
+ ["<CR>"] = actions.select_default,
+ ["<C-x>"] = actions.select_horizontal,
+ ["<C-v>"] = actions.select_vertical,
+ ["<C-k>"] = actions.select_tab,
+
+ ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
+ ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
+ ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
+ ["<M-q>"] = 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,
+
+ ["<Down>"] = actions.move_selection_next,
+ ["<Up>"] = actions.move_selection_previous,
+ ["gg"] = actions.move_to_top,
+ ["G"] = actions.move_to_bottom,
+
+ ["<C-u>"] = actions.preview_scrolling_up,
+ ["<C-d>"] = actions.preview_scrolling_down,
+
+ ["<PageUp>"] = actions.results_scrolling_up,
+ ["<PageDown>"] = 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,
+ }
+}