diff --git a/.config/nvim/.stylua.toml b/.config/nvim/.stylua.toml new file mode 100644 index 0000000..0435f67 --- /dev/null +++ b/.config/nvim/.stylua.toml @@ -0,0 +1,2 @@ +indent_type = "Spaces" +indent_width = 2 diff --git a/.config/nvim/lua/josean/core/colorscheme.lua b/.config/nvim/lua/josean/core/colorscheme.lua index a83ee95..1526426 100644 --- a/.config/nvim/lua/josean/core/colorscheme.lua +++ b/.config/nvim/lua/josean/core/colorscheme.lua @@ -2,6 +2,6 @@ -- in case it isn't installed local status, _ = pcall(vim.cmd, "colorscheme nightfly") if not status then - print("Colorscheme not found!") -- print error if colorscheme not installed - return + print("Colorscheme not found!") -- print error if colorscheme not installed + return end diff --git a/.config/nvim/lua/josean/plugins-setup.lua b/.config/nvim/lua/josean/plugins-setup.lua index 68e8ba0..14b2884 100644 --- a/.config/nvim/lua/josean/plugins-setup.lua +++ b/.config/nvim/lua/josean/plugins-setup.lua @@ -1,13 +1,13 @@ -- auto install packer if not installed local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) - vim.cmd([[packadd packer.nvim]]) - return true - end - return false + local fn = vim.fn + local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) + vim.cmd([[packadd packer.nvim]]) + return true + end + return false end local packer_bootstrap = ensure_packer() -- true if packer was just installed @@ -23,83 +23,83 @@ vim.cmd([[ -- import packer safely local status, packer = pcall(require, "packer") if not status then - return + return end -- add list of plugins to install return packer.startup(function(use) - -- packer can manage itself - use("wbthomason/packer.nvim") + -- packer can manage itself + use("wbthomason/packer.nvim") - use("nvim-lua/plenary.nvim") -- lua functions that many plugins use + use("nvim-lua/plenary.nvim") -- lua functions that many plugins use - use("bluz71/vim-nightfly-guicolors") -- preferred colorscheme + use("bluz71/vim-nightfly-guicolors") -- preferred colorscheme - use("christoomey/vim-tmux-navigator") -- tmux & split window navigation + use("christoomey/vim-tmux-navigator") -- tmux & split window navigation - use("szw/vim-maximizer") -- maximizes and restores current window + use("szw/vim-maximizer") -- maximizes and restores current window - -- essential plugins - use("tpope/vim-surround") -- add, delete, change surroundings (it's awesome) - use("vim-scripts/ReplaceWithRegister") -- replace with register contents using motion (gr + motion) + -- essential plugins + use("tpope/vim-surround") -- add, delete, change surroundings (it's awesome) + use("vim-scripts/ReplaceWithRegister") -- replace with register contents using motion (gr + motion) - -- commenting with gc - use("numToStr/Comment.nvim") + -- commenting with gc + use("numToStr/Comment.nvim") - -- file explorer - use("nvim-tree/nvim-tree.lua") + -- file explorer + use("nvim-tree/nvim-tree.lua") - -- vs-code like icons - use("kyazdani42/nvim-web-devicons") + -- vs-code like icons + use("kyazdani42/nvim-web-devicons") - -- statusline - use("nvim-lualine/lualine.nvim") + -- statusline + use("nvim-lualine/lualine.nvim") - -- fuzzy finding w/ telescope - use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- dependency for better sorting performance - use({ "nvim-telescope/telescope.nvim", branch = "0.1.x" }) -- fuzzy finder + -- fuzzy finding w/ telescope + use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- dependency for better sorting performance + use({ "nvim-telescope/telescope.nvim", branch = "0.1.x" }) -- fuzzy finder - -- autocompletion - use("hrsh7th/nvim-cmp") -- completion plugin - use("hrsh7th/cmp-buffer") -- source for text in buffer - use("hrsh7th/cmp-path") -- source for file system paths + -- autocompletion + use("hrsh7th/nvim-cmp") -- completion plugin + use("hrsh7th/cmp-buffer") -- source for text in buffer + use("hrsh7th/cmp-path") -- source for file system paths - -- snippets - use("L3MON4D3/LuaSnip") -- snippet engine - use("saadparwaiz1/cmp_luasnip") -- for autocompletion - use("rafamadriz/friendly-snippets") -- useful snippets + -- snippets + use("L3MON4D3/LuaSnip") -- snippet engine + use("saadparwaiz1/cmp_luasnip") -- for autocompletion + use("rafamadriz/friendly-snippets") -- useful snippets - -- managing & installing lsp servers, linters & formatters - use("williamboman/mason.nvim") -- in charge of managing lsp servers, linters & formatters - use("williamboman/mason-lspconfig.nvim") -- bridges gap b/w mason & lspconfig + -- managing & installing lsp servers, linters & formatters + use("williamboman/mason.nvim") -- in charge of managing lsp servers, linters & formatters + use("williamboman/mason-lspconfig.nvim") -- bridges gap b/w mason & lspconfig - -- configuring lsp servers - use("neovim/nvim-lspconfig") -- easily configure language servers - use("hrsh7th/cmp-nvim-lsp") -- for autocompletion - use({ "glepnir/lspsaga.nvim", branch = "main" }) -- enhanced lsp uis - use("jose-elias-alvarez/typescript.nvim") -- additional functionality for typescript server (e.g. rename file & update imports) - use("onsails/lspkind.nvim") -- vs-code like icons for autocompletion + -- configuring lsp servers + use("neovim/nvim-lspconfig") -- easily configure language servers + use("hrsh7th/cmp-nvim-lsp") -- for autocompletion + use({ "glepnir/lspsaga.nvim", branch = "main" }) -- enhanced lsp uis + use("jose-elias-alvarez/typescript.nvim") -- additional functionality for typescript server (e.g. rename file & update imports) + use("onsails/lspkind.nvim") -- vs-code like icons for autocompletion - -- formatting & linting - use("jose-elias-alvarez/null-ls.nvim") -- configure formatters & linters - use("jayp0521/mason-null-ls.nvim") -- bridges gap b/w mason & null-ls + -- formatting & linting + use("jose-elias-alvarez/null-ls.nvim") -- configure formatters & linters + use("jayp0521/mason-null-ls.nvim") -- bridges gap b/w mason & null-ls - -- treesitter configuration - use({ - "nvim-treesitter/nvim-treesitter", - run = function() - require("nvim-treesitter.install").update({ with_sync = true }) - end, - }) + -- treesitter configuration + use({ + "nvim-treesitter/nvim-treesitter", + run = function() + require("nvim-treesitter.install").update({ with_sync = true }) + end, + }) - -- auto closing - use("windwp/nvim-autopairs") -- autoclose parens, brackets, quotes, etc... - use({ "windwp/nvim-ts-autotag", after = "nvim-treesitter" }) -- autoclose tags + -- auto closing + use("windwp/nvim-autopairs") -- autoclose parens, brackets, quotes, etc... + use({ "windwp/nvim-ts-autotag", after = "nvim-treesitter" }) -- autoclose tags - -- git integration - use("lewis6991/gitsigns.nvim") -- show line modifications on left hand side + -- git integration + use("lewis6991/gitsigns.nvim") -- show line modifications on left hand side - if packer_bootstrap then - require("packer").sync() - end + if packer_bootstrap then + require("packer").sync() + end end) diff --git a/.config/nvim/lua/josean/plugins/autopairs.lua b/.config/nvim/lua/josean/plugins/autopairs.lua index 19890bb..0595e86 100644 --- a/.config/nvim/lua/josean/plugins/autopairs.lua +++ b/.config/nvim/lua/josean/plugins/autopairs.lua @@ -1,29 +1,29 @@ -- import nvim-autopairs safely local autopairs_setup, autopairs = pcall(require, "nvim-autopairs") if not autopairs_setup then - return + return end -- configure autopairs autopairs.setup({ - check_ts = true, -- enable treesitter - ts_config = { - lua = { "string" }, -- don't add pairs in lua string treesitter nodes - javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes - java = false, -- don't check treesitter on java - }, + check_ts = true, -- enable treesitter + ts_config = { + lua = { "string" }, -- don't add pairs in lua string treesitter nodes + javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes + java = false, -- don't check treesitter on java + }, }) -- import nvim-autopairs completion functionality safely local cmp_autopairs_setup, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp") if not cmp_autopairs_setup then - return + return end -- import nvim-cmp plugin safely (completions plugin) local cmp_setup, cmp = pcall(require, "cmp") if not cmp_setup then - return + return end -- make autopairs and completion work together diff --git a/.config/nvim/lua/josean/plugins/comment.lua b/.config/nvim/lua/josean/plugins/comment.lua index 35a7640..b9df5cd 100644 --- a/.config/nvim/lua/josean/plugins/comment.lua +++ b/.config/nvim/lua/josean/plugins/comment.lua @@ -1,7 +1,7 @@ -- import comment plugin safely local setup, comment = pcall(require, "Comment") if not setup then - return + return end -- enable comment diff --git a/.config/nvim/lua/josean/plugins/gitsigns.lua b/.config/nvim/lua/josean/plugins/gitsigns.lua index 22f7ba6..a2869c6 100644 --- a/.config/nvim/lua/josean/plugins/gitsigns.lua +++ b/.config/nvim/lua/josean/plugins/gitsigns.lua @@ -1,7 +1,7 @@ -- import gitsigns plugin safely local setup, gitsigns = pcall(require, "gitsigns") if not setup then - return + return end -- configure/enable gitsigns diff --git a/.config/nvim/lua/josean/plugins/lsp/lspconfig.lua b/.config/nvim/lua/josean/plugins/lsp/lspconfig.lua index 5fa18df..485c20a 100644 --- a/.config/nvim/lua/josean/plugins/lsp/lspconfig.lua +++ b/.config/nvim/lua/josean/plugins/lsp/lspconfig.lua @@ -1,48 +1,48 @@ -- import lspconfig plugin safely local lspconfig_status, lspconfig = pcall(require, "lspconfig") if not lspconfig_status then - return + return end -- import cmp-nvim-lsp plugin safely local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") if not cmp_nvim_lsp_status then - return + return end -- import typescript plugin safely local typescript_setup, typescript = pcall(require, "typescript") if not typescript_setup then - return + return end local keymap = vim.keymap -- for conciseness -- enable keybinds only for when lsp server available local on_attach = function(client, bufnr) - -- keybind options - local opts = { noremap = true, silent = true, buffer = bufnr } + -- keybind options + local opts = { noremap = true, silent = true, buffer = bufnr } - -- set keybinds - keymap.set("n", "gf", "Lspsaga lsp_finder", opts) -- show definition, references - keymap.set("n", "gD", "lua vim.lsp.buf.declaration()", opts) -- got to declaration - keymap.set("n", "gd", "Lspsaga peek_definition", opts) -- see definition and make edits in window - keymap.set("n", "gi", "lua vim.lsp.buf.implementation()", opts) -- go to implementation - keymap.set("n", "ca", "Lspsaga code_action", opts) -- see available code actions - keymap.set("n", "rn", "Lspsaga rename", opts) -- smart rename - keymap.set("n", "d", "Lspsaga show_line_diagnostics", opts) -- show diagnostics for line - keymap.set("n", "d", "Lspsaga show_cursor_diagnostics", opts) -- show diagnostics for cursor - keymap.set("n", "[d", "Lspsaga diagnostic_jump_prev", opts) -- jump to previous diagnostic in buffer - keymap.set("n", "]d", "Lspsaga diagnostic_jump_next", opts) -- jump to next diagnostic in buffer - keymap.set("n", "K", "Lspsaga hover_doc", opts) -- show documentation for what is under cursor - keymap.set("n", "o", "LSoutlineToggle", opts) -- see outline on right hand side + -- set keybinds + keymap.set("n", "gf", "Lspsaga lsp_finder", opts) -- show definition, references + keymap.set("n", "gD", "lua vim.lsp.buf.declaration()", opts) -- got to declaration + keymap.set("n", "gd", "Lspsaga peek_definition", opts) -- see definition and make edits in window + keymap.set("n", "gi", "lua vim.lsp.buf.implementation()", opts) -- go to implementation + keymap.set("n", "ca", "Lspsaga code_action", opts) -- see available code actions + keymap.set("n", "rn", "Lspsaga rename", opts) -- smart rename + keymap.set("n", "d", "Lspsaga show_line_diagnostics", opts) -- show diagnostics for line + keymap.set("n", "d", "Lspsaga show_cursor_diagnostics", opts) -- show diagnostics for cursor + keymap.set("n", "[d", "Lspsaga diagnostic_jump_prev", opts) -- jump to previous diagnostic in buffer + keymap.set("n", "]d", "Lspsaga diagnostic_jump_next", opts) -- jump to next diagnostic in buffer + keymap.set("n", "K", "Lspsaga hover_doc", opts) -- show documentation for what is under cursor + keymap.set("n", "o", "LSoutlineToggle", opts) -- see outline on right hand side - -- typescript specific keymaps (e.g. rename file and update imports) - if client.name == "tsserver" then - keymap.set("n", "rf", ":TypescriptRenameFile") -- rename file and update imports - keymap.set("n", "oi", ":TypescriptOrganizeImports") -- organize imports (not in youtube nvim video) - keymap.set("n", "ru", ":TypescriptRemoveUnused") -- remove unused variables (not in youtube nvim video) - end + -- typescript specific keymaps (e.g. rename file and update imports) + if client.name == "tsserver" then + keymap.set("n", "rf", ":TypescriptRenameFile") -- rename file and update imports + keymap.set("n", "oi", ":TypescriptOrganizeImports") -- organize imports (not in youtube nvim video) + keymap.set("n", "ru", ":TypescriptRemoveUnused") -- remove unused variables (not in youtube nvim video) + end end -- used to enable autocompletion (assign to every lsp server config) @@ -52,53 +52,53 @@ local capabilities = cmp_nvim_lsp.default_capabilities() -- (not in youtube nvim video) 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 = "" }) + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) end -- configure html server lspconfig["html"].setup({ - capabilities = capabilities, - on_attach = on_attach, + capabilities = capabilities, + on_attach = on_attach, }) -- configure typescript server with plugin typescript.setup({ - server = { - capabilities = capabilities, - on_attach = on_attach, - }, + server = { + capabilities = capabilities, + on_attach = on_attach, + }, }) -- configure css server lspconfig["cssls"].setup({ - capabilities = capabilities, - on_attach = on_attach, + capabilities = capabilities, + on_attach = on_attach, }) -- configure tailwindcss server lspconfig["tailwindcss"].setup({ - capabilities = capabilities, - on_attach = on_attach, + capabilities = capabilities, + on_attach = on_attach, }) -- configure lua server (with special settings) lspconfig["sumneko_lua"].setup({ - capabilities = capabilities, - on_attach = on_attach, - settings = { -- custom settings for lua - Lua = { - -- make the language server recognize "vim" global - diagnostics = { - globals = { "vim" }, - }, - workspace = { - -- make language server aware of runtime files - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, - }, - }, - }, - }, + capabilities = capabilities, + on_attach = on_attach, + settings = { -- custom settings for lua + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + workspace = { + -- make language server aware of runtime files + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, }) diff --git a/.config/nvim/lua/josean/plugins/lsp/lspsaga.lua b/.config/nvim/lua/josean/plugins/lsp/lspsaga.lua index 8ef575c..eea169e 100644 --- a/.config/nvim/lua/josean/plugins/lsp/lspsaga.lua +++ b/.config/nvim/lua/josean/plugins/lsp/lspsaga.lua @@ -1,18 +1,18 @@ -- import lspsaga safely local saga_status, saga = pcall(require, "lspsaga") if not saga_status then - return + return end saga.init_lsp_saga({ - -- keybinds for navigation in lspsaga window - move_in_saga = { prev = "", next = "" }, - -- use enter to open file with finder - finder_action_keys = { - open = "", - }, - -- use enter to open file with definition preview - definition_action_keys = { - edit = "", - }, + -- keybinds for navigation in lspsaga window + move_in_saga = { prev = "", next = "" }, + -- use enter to open file with finder + finder_action_keys = { + open = "", + }, + -- use enter to open file with definition preview + definition_action_keys = { + edit = "", + }, }) diff --git a/.config/nvim/lua/josean/plugins/lsp/mason.lua b/.config/nvim/lua/josean/plugins/lsp/mason.lua index c2a0729..2677f06 100644 --- a/.config/nvim/lua/josean/plugins/lsp/mason.lua +++ b/.config/nvim/lua/josean/plugins/lsp/mason.lua @@ -1,44 +1,44 @@ -- import mason plugin safely local mason_status, mason = pcall(require, "mason") if not mason_status then - return + return end -- import mason-lspconfig plugin safely local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig") if not mason_lspconfig_status then - return + return end -- import mason-null-ls plugin safely local mason_null_ls_status, mason_null_ls = pcall(require, "mason-null-ls") if not mason_null_ls_status then - return + return end -- enable mason mason.setup() mason_lspconfig.setup({ - -- list of servers for mason to install - ensure_installed = { - "tsserver", - "html", - "cssls", - "tailwindcss", - "sumneko_lua", - }, - -- auto-install configured servers (with lspconfig) - automatic_installation = true, -- not the same as ensure_installed + -- list of servers for mason to install + ensure_installed = { + "tsserver", + "html", + "cssls", + "tailwindcss", + "sumneko_lua", + }, + -- auto-install configured servers (with lspconfig) + automatic_installation = true, -- not the same as ensure_installed }) mason_null_ls.setup({ - -- list of formatters & linters for mason to install - ensure_installed = { - "prettier", -- ts/js formatter - "stylua", -- lua formatter - "eslint_d", -- ts/js linter - }, - -- auto-install configured formatters & linters (with null-ls) - automatic_installation = true, + -- list of formatters & linters for mason to install + ensure_installed = { + "prettier", -- ts/js formatter + "stylua", -- lua formatter + "eslint_d", -- ts/js linter + }, + -- auto-install configured formatters & linters (with null-ls) + automatic_installation = true, }) diff --git a/.config/nvim/lua/josean/plugins/lsp/null-ls.lua b/.config/nvim/lua/josean/plugins/lsp/null-ls.lua index a80fc69..6f900b1 100644 --- a/.config/nvim/lua/josean/plugins/lsp/null-ls.lua +++ b/.config/nvim/lua/josean/plugins/lsp/null-ls.lua @@ -1,7 +1,7 @@ -- import null-ls plugin safely local setup, null_ls = pcall(require, "null-ls") if not setup then - return + return end -- for conciseness @@ -13,36 +13,36 @@ local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -- configure null_ls null_ls.setup({ - -- setup formatters & linters - sources = { - -- to disable file types use - -- "formatting.prettier.with({disabled_filetypes: {}})" (see null-ls docs) - formatting.prettier, -- js/ts formatter - formatting.stylua, -- lua formatter - diagnostics.eslint_d.with({ -- js/ts linter - -- only enable eslint if root has .eslintrc.js (not in youtube nvim video) - condition = function(utils) - return utils.root_has_file(".eslintrc.js") -- change file extension if you use something else - end, - }), - }, - -- configure format on save - on_attach = function(current_client, bufnr) - if current_client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format({ - filter = function(client) - -- only use null-ls for formatting instead of lsp server - return client.name == "null-ls" - end, - bufnr = bufnr, - }) - end, - }) - end - end, + -- setup formatters & linters + sources = { + -- to disable file types use + -- "formatting.prettier.with({disabled_filetypes: {}})" (see null-ls docs) + formatting.prettier, -- js/ts formatter + formatting.stylua, -- lua formatter + diagnostics.eslint_d.with({ -- js/ts linter + -- only enable eslint if root has .eslintrc.js (not in youtube nvim video) + condition = function(utils) + return utils.root_has_file(".eslintrc.js") -- change file extension if you use something else + end, + }), + }, + -- configure format on save + on_attach = function(current_client, bufnr) + if current_client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ + filter = function(client) + -- only use null-ls for formatting instead of lsp server + return client.name == "null-ls" + end, + bufnr = bufnr, + }) + end, + }) + end + end, }) diff --git a/.config/nvim/lua/josean/plugins/lualine.lua b/.config/nvim/lua/josean/plugins/lualine.lua index c3b54ab..fdc35b3 100644 --- a/.config/nvim/lua/josean/plugins/lualine.lua +++ b/.config/nvim/lua/josean/plugins/lualine.lua @@ -1,7 +1,7 @@ -- import lualine plugin safely local status, lualine = pcall(require, "lualine") if not status then - return + return end -- get lualine nightfly theme @@ -9,11 +9,11 @@ local lualine_nightfly = require("lualine.themes.nightfly") -- new colors for theme local new_colors = { - blue = "#65D1FF", - green = "#3EFFDC", - violet = "#FF61EF", - yellow = "#FFDA7B", - black = "#000000", + blue = "#65D1FF", + green = "#3EFFDC", + violet = "#FF61EF", + yellow = "#FFDA7B", + black = "#000000", } -- change nightlfy theme colors @@ -21,16 +21,16 @@ lualine_nightfly.normal.a.bg = new_colors.blue lualine_nightfly.insert.a.bg = new_colors.green lualine_nightfly.visual.a.bg = new_colors.violet lualine_nightfly.command = { - a = { - gui = "bold", - bg = new_colors.yellow, - fg = new_colors.black, -- black - }, + a = { + gui = "bold", + bg = new_colors.yellow, + fg = new_colors.black, -- black + }, } -- configure lualine with modified theme lualine.setup({ - options = { - theme = lualine_nightfly, - }, + options = { + theme = lualine_nightfly, + }, }) diff --git a/.config/nvim/lua/josean/plugins/nvim-cmp.lua b/.config/nvim/lua/josean/plugins/nvim-cmp.lua index af886b4..974d853 100644 --- a/.config/nvim/lua/josean/plugins/nvim-cmp.lua +++ b/.config/nvim/lua/josean/plugins/nvim-cmp.lua @@ -1,19 +1,19 @@ -- import nvim-cmp plugin safely local cmp_status, cmp = pcall(require, "cmp") if not cmp_status then - return + return end -- import luasnip plugin safely local luasnip_status, luasnip = pcall(require, "luasnip") if not luasnip_status then - return + return end -- import lspkind plugin safely local lspkind_status, lspkind = pcall(require, "lspkind") if not lspkind_status then - return + return end -- load vs-code like snippets from plugins (e.g. friendly-snippets) @@ -22,32 +22,32 @@ require("luasnip/loaders/from_vscode").lazy_load() vim.opt.completeopt = "menu,menuone,noselect" cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(), -- previous suggestion - [""] = cmp.mapping.select_next_item(), -- next suggestion - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), -- show completion suggestions - [""] = cmp.mapping.abort(), -- close completion window - [""] = cmp.mapping.confirm({ select = false }), - }), - -- sources for autocompletion - sources = cmp.config.sources({ - { name = "nvim_lsp" }, -- lsp - { name = "luasnip" }, -- snippets - { name = "buffer" }, -- text within current buffer - { name = "path" }, -- file system paths - }), - -- configure lspkind for vs-code like icons - formatting = { - format = lspkind.cmp_format({ - maxwidth = 50, - ellipsis_char = "...", - }), - }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), -- previous suggestion + [""] = cmp.mapping.select_next_item(), -- next suggestion + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.abort(), -- close completion window + [""] = cmp.mapping.confirm({ select = false }), + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp" }, -- lsp + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), + -- configure lspkind for vs-code like icons + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, }) diff --git a/.config/nvim/lua/josean/plugins/nvim-tree.lua b/.config/nvim/lua/josean/plugins/nvim-tree.lua index e1e14e4..3e8056b 100644 --- a/.config/nvim/lua/josean/plugins/nvim-tree.lua +++ b/.config/nvim/lua/josean/plugins/nvim-tree.lua @@ -1,7 +1,7 @@ -- import nvim-tree plugin safely local setup, nvimtree = pcall(require, "nvim-tree") if not setup then - return + return end -- recommended settings from nvim-tree documentation @@ -13,25 +13,25 @@ vim.cmd([[ highlight NvimTreeIndentMarker guifg=#3FC5FF ]]) -- configure nvim-tree nvimtree.setup({ - -- change folder arrow icons - renderer = { - icons = { - glyphs = { - folder = { - arrow_closed = "", -- arrow when folder is closed - arrow_open = "", -- arrow when folder is open - }, - }, - }, - }, - -- disable window_picker for - -- explorer to work well with - -- window splits - actions = { - open_file = { - window_picker = { - enable = false, - }, - }, - }, + -- change folder arrow icons + renderer = { + icons = { + glyphs = { + folder = { + arrow_closed = "", -- arrow when folder is closed + arrow_open = "", -- arrow when folder is open + }, + }, + }, + }, + -- disable window_picker for + -- explorer to work well with + -- window splits + actions = { + open_file = { + window_picker = { + enable = false, + }, + }, + }, }) diff --git a/.config/nvim/lua/josean/plugins/telescope.lua b/.config/nvim/lua/josean/plugins/telescope.lua index a70a5e9..9c6e725 100644 --- a/.config/nvim/lua/josean/plugins/telescope.lua +++ b/.config/nvim/lua/josean/plugins/telescope.lua @@ -1,27 +1,27 @@ -- import telescope plugin safely local telescope_setup, telescope = pcall(require, "telescope") if not telescope_setup then - return + return end -- import telescope actions safely local actions_setup, actions = pcall(require, "telescope.actions") if not actions_setup then - return + return end -- configure telescope telescope.setup({ - -- configure custom mappings - defaults = { - mappings = { - i = { - [""] = actions.move_selection_previous, -- move to prev result - [""] = actions.move_selection_next, -- move to next result - [""] = actions.send_selected_to_qflist + actions.open_qflist, -- send selected to quickfixlist - }, - }, - }, + -- configure custom mappings + defaults = { + mappings = { + i = { + [""] = actions.move_selection_previous, -- move to prev result + [""] = actions.move_selection_next, -- move to next result + [""] = actions.send_selected_to_qflist + actions.open_qflist, -- send selected to quickfixlist + }, + }, + }, }) telescope.load_extension("fzf") diff --git a/.config/nvim/lua/josean/plugins/treesitter.lua b/.config/nvim/lua/josean/plugins/treesitter.lua index 2c0a7d5..8168caf 100644 --- a/.config/nvim/lua/josean/plugins/treesitter.lua +++ b/.config/nvim/lua/josean/plugins/treesitter.lua @@ -1,37 +1,37 @@ -- import nvim-treesitter plugin safely local status, treesitter = pcall(require, "nvim-treesitter.configs") if not status then - return + return end -- configure treesitter treesitter.setup({ - -- enable syntax highlighting - highlight = { - enable = true, - }, - -- enable indentation - indent = { enable = true }, - -- enable autotagging (w/ nvim-ts-autotag plugin) - autotag = { enable = true }, - -- ensure these language parsers are installed - ensure_installed = { - "json", - "javascript", - "typescript", - "tsx", - "yaml", - "html", - "css", - "markdown", - "svelte", - "graphql", - "bash", - "lua", - "vim", - "dockerfile", - "gitignore", - }, - -- auto install above language parsers - auto_install = true, + -- enable syntax highlighting + highlight = { + enable = true, + }, + -- enable indentation + indent = { enable = true }, + -- enable autotagging (w/ nvim-ts-autotag plugin) + autotag = { enable = true }, + -- ensure these language parsers are installed + ensure_installed = { + "json", + "javascript", + "typescript", + "tsx", + "yaml", + "html", + "css", + "markdown", + "svelte", + "graphql", + "bash", + "lua", + "vim", + "dockerfile", + "gitignore", + }, + -- auto install above language parsers + auto_install = true, })