From 400e7eeb5e3810531410231eb7a42c164268cdf4 Mon Sep 17 00:00:00 2001 From: aleidk Date: Wed, 20 Sep 2023 19:23:05 -0300 Subject: [PATCH 1/3] update --- config/nvim/init.lua | 16 +-- config/nvim/lua/aleidk/IDE/init.lua | 1 - config/nvim/lua/aleidk/IDE/lsp.lua | 92 -------------- .../nvim/lua/aleidk/plugins/colorscheme.lua | 3 + config/nvim/lua/aleidk/plugins/init.lua | 17 --- config/nvim/lua/aleidk/plugins/lsp.lua | 119 ++++++++++++++++++ config/nvim/lua/aleidk/plugins/noice.lua | 78 ++++++------ config/tmux/tmux.conf | 8 ++ exports/copr.txt | 1 + exports/dnf.txt | 1 + 10 files changed, 180 insertions(+), 156 deletions(-) delete mode 100644 config/nvim/lua/aleidk/IDE/lsp.lua create mode 100644 config/nvim/lua/aleidk/plugins/lsp.lua diff --git a/config/nvim/init.lua b/config/nvim/init.lua index b2b8d91..4cbee4e 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -6,14 +6,14 @@ require("aleidk.options") -- Install package manager https://github.com/folke/lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) diff --git a/config/nvim/lua/aleidk/IDE/init.lua b/config/nvim/lua/aleidk/IDE/init.lua index 3b6291b..d3ac6f2 100644 --- a/config/nvim/lua/aleidk/IDE/init.lua +++ b/config/nvim/lua/aleidk/IDE/init.lua @@ -1,3 +1,2 @@ -require("aleidk.IDE.lsp") require("aleidk.IDE.completion") require("aleidk.IDE.null-ls") diff --git a/config/nvim/lua/aleidk/IDE/lsp.lua b/config/nvim/lua/aleidk/IDE/lsp.lua deleted file mode 100644 index 8997c6e..0000000 --- a/config/nvim/lua/aleidk/IDE/lsp.lua +++ /dev/null @@ -1,92 +0,0 @@ --- LSP settings. --- This function gets run when an LSP connects to a particular buffer. -local on_attach = function(_, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = "LSP: " .. desc - end - - vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) - end - - nmap("rn", vim.lsp.buf.rename, "[R]e[n]ame") - nmap("ca", vim.lsp.buf.code_action, "[C]ode [A]ction") - - nmap("gd", vim.lsp.buf.definition, "Go to definition") - nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") - nmap("gI", vim.lsp.buf.implementation, "Go to Implementation") - - -- See `:help K` for why this keymap - nmap("K", vim.lsp.buf.hover, "Hover Documentation") - nmap("", vim.lsp.buf.signature_help, "Signature Documentation") - - -- Lesser used LSP functionality - nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") - nmap("wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") - nmap("wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") - nmap("wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, "[W]orkspace [L]ist Folders") - - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) - vim.lsp.buf.format() - end, { desc = "Format current buffer with LSP" }) -end - --- Enable the following language servers --- Feel free to add/remove any LSPs that you want here. They will automatically be installed. --- --- Add any additional override configuration in the following tables. They will be passed to --- the `settings` field of the server config. You must look up that documentation yourself. -local servers = { - bashls = {}, - cssls = {}, - dockerls = {}, - emmet_ls = {}, - html = {}, - pyright = {}, - rust_analyzer = {}, - sqlls = {}, - tsserver = {}, - yamlls = {}, - lua_ls = { - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - }, - }, -} - --- Diagnostic keymaps --- vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) --- vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) --- vim.keymap.set("n", "e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) --- vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) - --- nvim-cmp supports additional completion capabilities, so broadcast that to servers -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) - --- Ensure the servers above are installed -local mason_lspconfig = require("mason-lspconfig") - -mason_lspconfig.setup({ - ensure_installed = vim.tbl_keys(servers), -}) - -mason_lspconfig.setup_handlers({ - function(server_name) - require("lspconfig")[server_name].setup({ - capabilities = capabilities, - on_attach = on_attach, - settings = servers[server_name], - }) - end, -}) diff --git a/config/nvim/lua/aleidk/plugins/colorscheme.lua b/config/nvim/lua/aleidk/plugins/colorscheme.lua index 8132836..d69819e 100644 --- a/config/nvim/lua/aleidk/plugins/colorscheme.lua +++ b/config/nvim/lua/aleidk/plugins/colorscheme.lua @@ -5,6 +5,9 @@ return { opts = { flavour = "macchiato", transparent_background = true, + integrations = { + fidget = true, + }, }, config = function(_, opts) diff --git a/config/nvim/lua/aleidk/plugins/init.lua b/config/nvim/lua/aleidk/plugins/init.lua index 82eb37a..2e4b824 100644 --- a/config/nvim/lua/aleidk/plugins/init.lua +++ b/config/nvim/lua/aleidk/plugins/init.lua @@ -8,23 +8,6 @@ return { -- Detect tabstop and shiftwidth automatically "tpope/vim-sleuth", - { - -- LSP Configuration & Plugins - "neovim/nvim-lspconfig", - dependencies = { - -- Automatically install LSPs to stdpath for neovim - { "williamboman/mason.nvim", config = true }, - "williamboman/mason-lspconfig.nvim", - - -- Useful status updates for LSP - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { "j-hui/fidget.nvim", opts = {} }, - - -- Additional lua configuration, makes nvim stuff amazing! - { "folke/neodev.nvim", opts = {} }, - }, - }, - { -- Autocompletion "hrsh7th/nvim-cmp", diff --git a/config/nvim/lua/aleidk/plugins/lsp.lua b/config/nvim/lua/aleidk/plugins/lsp.lua new file mode 100644 index 0000000..0014afc --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/lsp.lua @@ -0,0 +1,119 @@ +return { + -- LSP Configuration & Plugins + "neovim/nvim-lspconfig", + dependencies = { + -- Automatically install LSPs to stdpath for neovim + { "williamboman/mason.nvim", config = true }, + "williamboman/mason-lspconfig.nvim", + + -- Useful status updates for LSP + { + "j-hui/fidget.nvim", + tag = "legacy", + event = "LspAttach", + opts = { + window = { + blend = 0, + }, + }, + }, + + -- Additional lua configuration, makes nvim stuff amazing! + { "folke/neodev.nvim", opts = {} }, + }, + + config = function() + -- LSP settings. + -- This function gets run when an LSP connects to a particular buffer. + local on_attach = function(_, bufnr) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = "LSP: " .. desc + end + + vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) + end + + nmap("rn", vim.lsp.buf.rename, "[R]e[n]ame") + nmap("ca", vim.lsp.buf.code_action, "[C]ode [A]ction") + + nmap("gd", vim.lsp.buf.definition, "Go to definition") + nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") + nmap("gI", vim.lsp.buf.implementation, "Go to Implementation") + + -- See `:help K` for why this keymap + nmap("K", vim.lsp.buf.hover, "Hover Documentation") + nmap("", vim.lsp.buf.signature_help, "Signature Documentation") + + -- Lesser used LSP functionality + nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + nmap("wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") + nmap("wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") + nmap("wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, "[W]orkspace [L]ist Folders") + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) + vim.lsp.buf.format() + end, { desc = "Format current buffer with LSP" }) + end + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. They will be passed to + -- the `settings` field of the server config. You must look up that documentation yourself. + local servers = { + bashls = {}, + cssls = {}, + dockerls = {}, + emmet_ls = {}, + html = {}, + pyright = {}, + rust_analyzer = {}, + sqlls = {}, + tsserver = {}, + yamlls = {}, + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, + } + + -- Diagnostic keymaps + -- vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) + -- vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) + -- vim.keymap.set("n", "e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) + -- vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) + + -- nvim-cmp supports additional completion capabilities, so broadcast that to servers + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) + + -- Ensure the servers above are installed + local mason_lspconfig = require("mason-lspconfig") + + mason_lspconfig.setup({ + ensure_installed = vim.tbl_keys(servers), + }) + + mason_lspconfig.setup_handlers({ + function(server_name) + require("lspconfig")[server_name].setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + }) + end, + }) + end, +} diff --git a/config/nvim/lua/aleidk/plugins/noice.lua b/config/nvim/lua/aleidk/plugins/noice.lua index 3f01390..92ee963 100644 --- a/config/nvim/lua/aleidk/plugins/noice.lua +++ b/config/nvim/lua/aleidk/plugins/noice.lua @@ -1,42 +1,44 @@ return { - "folke/noice.nvim", - event = "VeryLazy", - dependencies = { - -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries - "MunifTanjim/nui.nvim", - -- OPTIONAL: - -- `nvim-notify` is only needed, if you want to use the notification view. - -- If not available, we use `mini` as the fallback - "rcarriga/nvim-notify", - }, - opts = { - lsp = { - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - }, - routes = { - { - filter = { - event = "msg_show", - any = { - { find = "%d+L, %d+B" }, - { find = "; after #%d+" }, - { find = "; before #%d+" }, - }, - }, - view = "mini", - }, - }, - presets = { - bottom_search = true, - command_palette = true, - long_message_to_split = true, - inc_rename = true, - }, - }, + "folke/noice.nvim", + event = "VeryLazy", + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + "MunifTanjim/nui.nvim", + -- OPTIONAL: + -- `nvim-notify` is only needed, if you want to use the notification view. + -- If not available, we use `mini` as the fallback + { "rcarriga/nvim-notify", opts = { + background_colour = "#000000", + } }, + }, + opts = { + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + }, + routes = { + { + filter = { + event = "msg_show", + any = { + { find = "%d+L, %d+B" }, + { find = "; after #%d+" }, + { find = "; before #%d+" }, + }, + }, + view = "mini", + }, + }, + presets = { + bottom_search = true, + command_palette = true, + long_message_to_split = true, + inc_rename = true, + }, + }, -- stylua: ignore keys = { { diff --git a/config/tmux/tmux.conf b/config/tmux/tmux.conf index e9a0a29..01a5e3b 100644 --- a/config/tmux/tmux.conf +++ b/config/tmux/tmux.conf @@ -50,6 +50,8 @@ bind n new-window -c "#{pane_current_path}" bind h previous-window bind l next-window +# set -g status-right '#(bartib current | sed -n 3p | awk \'{print $NF}\')' + ## Plugins run -b '~/.tmux/plugins/tpm/tpm' @@ -67,6 +69,12 @@ set -g @plugin 'tmux-plugins/tpm' ## Plugin Config set -g @catppuccin_flavour 'macchiato' set -g @catppuccin_window_tabs_enabled on # or off to disable window_tabs +set -g @catppuccin_status_modules_right "directory session" +set -g @catppuccin_status_left_separator " " +set -g @catppuccin_status_right_separator "" +set -g @catppuccin_status_right_separator_inverse "no" +set -g @catppuccin_status_fill "icon" +set -g @catppuccin_status_connect_separator "no" TMUX_FZF_LAUNCH_KEY="w" TMUX_FZF_OPTIONS="-p -w 80% -h 60% -m" diff --git a/exports/copr.txt b/exports/copr.txt index 649b0f8..e7b43d7 100644 --- a/exports/copr.txt +++ b/exports/copr.txt @@ -1,2 +1,3 @@ atim/lazygit atim/starship +the4runner/firefox-dev diff --git a/exports/dnf.txt b/exports/dnf.txt index 6e1f689..c33ab1e 100644 --- a/exports/dnf.txt +++ b/exports/dnf.txt @@ -21,3 +21,4 @@ tealdeer tmux tree-sitter-cli zsh +firefox-dev From 2e76dd1cab962b2e117571b160245e82a4ff2651 Mon Sep 17 00:00:00 2001 From: aleidk Date: Wed, 20 Sep 2023 19:58:35 -0300 Subject: [PATCH 2/3] add linter and formatting support --- config/nvim/lua/aleidk/IDE/init.lua | 1 - config/nvim/lua/aleidk/IDE/null-ls.lua | 38 -------------------- config/nvim/lua/aleidk/plugins/formatter.lua | 22 ++++++++++++ config/nvim/lua/aleidk/plugins/linters.lua | 19 ++++++++++ config/nvim/lua/aleidk/plugins/lsp.lua | 2 +- config/nvim/lua/aleidk/plugins/mason.lua | 9 +++++ 6 files changed, 51 insertions(+), 40 deletions(-) delete mode 100644 config/nvim/lua/aleidk/IDE/null-ls.lua create mode 100644 config/nvim/lua/aleidk/plugins/formatter.lua create mode 100644 config/nvim/lua/aleidk/plugins/linters.lua create mode 100644 config/nvim/lua/aleidk/plugins/mason.lua diff --git a/config/nvim/lua/aleidk/IDE/init.lua b/config/nvim/lua/aleidk/IDE/init.lua index d3ac6f2..4a64e65 100644 --- a/config/nvim/lua/aleidk/IDE/init.lua +++ b/config/nvim/lua/aleidk/IDE/init.lua @@ -1,2 +1 @@ require("aleidk.IDE.completion") -require("aleidk.IDE.null-ls") diff --git a/config/nvim/lua/aleidk/IDE/null-ls.lua b/config/nvim/lua/aleidk/IDE/null-ls.lua deleted file mode 100644 index 28f1981..0000000 --- a/config/nvim/lua/aleidk/IDE/null-ls.lua +++ /dev/null @@ -1,38 +0,0 @@ --- Linter and formatter configuration - -require("mason-null-ls").setup({ - handlers = {}, -- this make mason-null-ls to auto setup handlers - ensure_installed = { - "blade_formatter", - "blue", - "eslint_d", - "fixjson", - "gitlint", - "intelephense", - "markdownlint", - "php-cs-fixer", - "prettierd", - "shellcheck", - "shfmt", - "sql-formatter", - "stylua", - "yamlint", - }, -}) - -local null_ls = require("null-ls.builtins") - -require("null-ls").setup({ - sources = { - null_ls.formatting.prettierd.with({ - disabled_filetypes = { "markdown" }, - }), - - null_ls.formatting.phpcsfixer.with({ - extra_args = { - "--config", - "$HOME/.config/php-cs-fixer-conf.php", - }, - }), - }, -}) diff --git a/config/nvim/lua/aleidk/plugins/formatter.lua b/config/nvim/lua/aleidk/plugins/formatter.lua new file mode 100644 index 0000000..e6a6b9c --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/formatter.lua @@ -0,0 +1,22 @@ +return { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + -- Conform will run multiple formatters sequentially + lua = { "stylua" }, + python = { "black" }, + -- Use a sub-list to run only the first available formatter + javascript = { { "prettierd", "prettier" } }, + typescript = { { "prettierd", "prettier" } }, + javascriptreact = { { "prettierd", "prettier" } }, + typescriptreact = { { "prettierd", "prettier" } }, + -- Use the "_" filetype to run formatters on filetypes that don't + -- have other formatters configured. + ["_"] = { "trim_whitespace" }, + }, + format_on_save = { + timeout_ms = 500, + lsp_fallback = true, + }, + }, +} diff --git a/config/nvim/lua/aleidk/plugins/linters.lua b/config/nvim/lua/aleidk/plugins/linters.lua new file mode 100644 index 0000000..6e6b2b1 --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/linters.lua @@ -0,0 +1,19 @@ +return { + "mfussenegger/nvim-lint", + event = "VeryLazy", + config = function() + require("lint").linters_by_ft = { + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + javascriptreact = { "eslint_d" }, + typescriptreact = { "eslint_d" }, + -- astro = { "eslint_d" }, + } + + vim.api.nvim_create_autocmd({ "BufWritePost" }, { + callback = function() + require("lint").try_lint() + end, + }) + end, +} diff --git a/config/nvim/lua/aleidk/plugins/lsp.lua b/config/nvim/lua/aleidk/plugins/lsp.lua index 0014afc..a7ae31d 100644 --- a/config/nvim/lua/aleidk/plugins/lsp.lua +++ b/config/nvim/lua/aleidk/plugins/lsp.lua @@ -3,7 +3,7 @@ return { "neovim/nvim-lspconfig", dependencies = { -- Automatically install LSPs to stdpath for neovim - { "williamboman/mason.nvim", config = true }, + { "williamboman/mason.nvim" }, "williamboman/mason-lspconfig.nvim", -- Useful status updates for LSP diff --git a/config/nvim/lua/aleidk/plugins/mason.lua b/config/nvim/lua/aleidk/plugins/mason.lua new file mode 100644 index 0000000..95a9775 --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/mason.lua @@ -0,0 +1,9 @@ +return { + "williamboman/mason.nvim", + opts = { + ensure_installed = { + "typescript-language-server", + "eslint_d", + }, + }, +} From 30a074d5f3bd7cc8b7ae9a2281437f98776efe79 Mon Sep 17 00:00:00 2001 From: aleidk Date: Sun, 1 Oct 2023 17:23:04 -0300 Subject: [PATCH 3/3] update completition configuration --- config/alacritty/alacritty.yml | 4 +- config/nvim/init.lua | 1 - config/nvim/lua/aleidk/IDE/completion.lua | 44 ------------ config/nvim/lua/aleidk/IDE/init.lua | 1 - config/nvim/lua/aleidk/constants.lua | 2 +- .../nvim/lua/aleidk/plugins/colorscheme.lua | 10 ++- config/nvim/lua/aleidk/plugins/completion.lua | 72 +++++++++++++++++++ config/nvim/lua/aleidk/plugins/luasnip.lua | 27 +++++++ 8 files changed, 111 insertions(+), 50 deletions(-) delete mode 100644 config/nvim/lua/aleidk/IDE/completion.lua delete mode 100644 config/nvim/lua/aleidk/IDE/init.lua create mode 100644 config/nvim/lua/aleidk/plugins/completion.lua create mode 100644 config/nvim/lua/aleidk/plugins/luasnip.lua diff --git a/config/alacritty/alacritty.yml b/config/alacritty/alacritty.yml index 19759f3..4ff033b 100644 --- a/config/alacritty/alacritty.yml +++ b/config/alacritty/alacritty.yml @@ -14,8 +14,8 @@ import: # Any items in the `env` entry below will be added as # environment variables. Some entries may override variables # set by alacritty itself. -#env: -# TERM variable +env: + TERM: xterm-256color # # This value is used to set the `$TERM` environment variable for # each instance of Alacritty. If it is not present, alacritty will diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 4cbee4e..a9b3bcc 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -24,4 +24,3 @@ require("lazy").setup("aleidk.plugins") require("aleidk.keymaps") require("aleidk.autocmds") -require("aleidk.IDE") diff --git a/config/nvim/lua/aleidk/IDE/completion.lua b/config/nvim/lua/aleidk/IDE/completion.lua deleted file mode 100644 index 9bed8cd..0000000 --- a/config/nvim/lua/aleidk/IDE/completion.lua +++ /dev/null @@ -1,44 +0,0 @@ --- nvim-cmp setup -local cmp = require("cmp") -local luasnip = require("luasnip") - -luasnip.config.setup({}) - -cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete({}), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - 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" }), - }), - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - }, -}) diff --git a/config/nvim/lua/aleidk/IDE/init.lua b/config/nvim/lua/aleidk/IDE/init.lua deleted file mode 100644 index 4a64e65..0000000 --- a/config/nvim/lua/aleidk/IDE/init.lua +++ /dev/null @@ -1 +0,0 @@ -require("aleidk.IDE.completion") diff --git a/config/nvim/lua/aleidk/constants.lua b/config/nvim/lua/aleidk/constants.lua index ba67ee5..0d9495c 100644 --- a/config/nvim/lua/aleidk/constants.lua +++ b/config/nvim/lua/aleidk/constants.lua @@ -50,7 +50,7 @@ return { Package = " ", Property = " ", Reference = " ", - Snippet = " ", + Snippet = " ", String = " ", Struct = " ", Text = " ", diff --git a/config/nvim/lua/aleidk/plugins/colorscheme.lua b/config/nvim/lua/aleidk/plugins/colorscheme.lua index d69819e..412d3c8 100644 --- a/config/nvim/lua/aleidk/plugins/colorscheme.lua +++ b/config/nvim/lua/aleidk/plugins/colorscheme.lua @@ -1,4 +1,4 @@ -return { +return { -- Change colors.none if not using a transparent background "catppuccin/nvim", priority = 1000, lazy = false, @@ -7,7 +7,15 @@ return { transparent_background = true, integrations = { fidget = true, + cmp = true, }, + custom_highlights = function(colors) + return { + Pmenu = { bg = colors.none, blend = 0 }, + FloatBorder = { bg = colors.none }, + CmpItemMenu = { fg = colors.text, bg = colors.none }, + } + end, }, config = function(_, opts) diff --git a/config/nvim/lua/aleidk/plugins/completion.lua b/config/nvim/lua/aleidk/plugins/completion.lua new file mode 100644 index 0000000..0f5652c --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/completion.lua @@ -0,0 +1,72 @@ +return { + "hrsh7th/nvim-cmp", + version = false, -- last release is way too old + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + }, + opts = function() + vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) + local cmp = require("cmp") + local defaults = require("cmp.config.default")() + local window_opts = { + border = "rounded", + side_padding = 1, + winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None", + } + return { + completion = { + completeopt = "menu,menuone,noinsert", + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }), + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(_, item) + local icons = require("aleidk.constants").icons.kinds + if icons[item.kind] then + item.kind = icons[item.kind] .. item.kind + end + return item + end, + }, + window = { + completion = cmp.config.window.bordered(window_opts), + documentation = cmp.config.window.bordered(window_opts), + }, + experimental = { + ghost_text = { + hl_group = "CmpGhostText", + }, + }, + sorting = defaults.sorting, + } + end, +} diff --git a/config/nvim/lua/aleidk/plugins/luasnip.lua b/config/nvim/lua/aleidk/plugins/luasnip.lua new file mode 100644 index 0000000..bf6d8ef --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/luasnip.lua @@ -0,0 +1,27 @@ +return { + "L3MON4D3/LuaSnip", + dependencies = { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + opts = { + history = true, + delete_check_events = "TextChanged", + }, + -- stylua: ignore + keys = { + { + "", + function() + return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" + end, + expr = true, + silent = true, + mode = "i", + }, + { "", function() require("luasnip").jump(1) end, mode = "s" }, + { "", function() require("luasnip").jump(-1) end, mode = { "i", "s" } }, + }, +}