diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore new file mode 100644 index 0000000..fca6e4f --- /dev/null +++ b/.config/nvim/.gitignore @@ -0,0 +1,44 @@ +# Compiled Lua sources +luac.out + + +# luarocks build files +*.src.rock +*.zip +*.tar.gz + +# Object files +*.o +*.os +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo +*.def +*.exp + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + + +plugin/packer_compiled.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..3e2db9a --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,16 @@ +require("josean.plugins-setup") +require("josean.core.options") +require("josean.core.keymaps") +require("josean.core.colorscheme") +require("josean.plugins.comment") +require("josean.plugins.nvim-tree") +require("josean.plugins.lualine") +require("josean.plugins.telescope") +require("josean.plugins.nvim-cmp") +require("josean.plugins.lsp.mason") +require("josean.plugins.lsp.lspsaga") +require("josean.plugins.lsp.lspconfig") +require("josean.plugins.lsp.null-ls") +require("josean.plugins.autopairs") +require("josean.plugins.treesitter") +require("josean.plugins.gitsigns") diff --git a/.config/nvim/lua/josean/core/colorscheme.lua b/.config/nvim/lua/josean/core/colorscheme.lua new file mode 100644 index 0000000..a83ee95 --- /dev/null +++ b/.config/nvim/lua/josean/core/colorscheme.lua @@ -0,0 +1,7 @@ +-- set colorscheme to nightfly with protected call +-- 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 +end diff --git a/.config/nvim/lua/josean/core/keymaps.lua b/.config/nvim/lua/josean/core/keymaps.lua new file mode 100644 index 0000000..2ebfd5a --- /dev/null +++ b/.config/nvim/lua/josean/core/keymaps.lua @@ -0,0 +1,58 @@ +-- set leader key to space +vim.g.mapleader = " " + +local keymap = vim.keymap -- for conciseness + +--------------------- +-- General Keymaps +--------------------- + +-- use jk to exit insert mode +keymap.set("i", "jk", "") + +-- clear search highlights +keymap.set("n", "nh", ":nohl") + +-- delete single character without copying into register +keymap.set("n", "x", '"_x') + +-- increment/decrement numbers +keymap.set("n", "+", "") +keymap.set("n", "-", "") + +-- window management +keymap.set("n", "sv", "v") -- split window vertically +keymap.set("n", "sh", "s") -- split window horizontally +keymap.set("n", "se", "=") -- make split windows equal width & height +keymap.set("n", "sx", ":close") -- close current split window + +keymap.set("n", "to", ":tabnew") -- open new tab +keymap.set("n", "tx", ":tabclose") -- close current tab +keymap.set("n", "tn", ":tabn") -- go to next tab +keymap.set("n", "tp", ":tabp") -- go to previous tab + +---------------------- +-- Plugin Keybinds +---------------------- + +-- vim-maximizer +keymap.set("n", "sm", ":MaximizerToggle") -- toggle split window maximization + +-- nvim-tree +keymap.set("n", "e", ":NvimTreeToggle") -- toggle file explorer + +-- telescope +keymap.set("n", "ff", "Telescope find_files") -- find files within current working directory, respects .gitignore +keymap.set("n", "fs", "Telescope live_grep") -- find string in current working directory as you type +keymap.set("n", "fc", "Telescope grep_string") -- find string under cursor in current working directory +keymap.set("n", "fb", "Telescope buffers") -- list open buffers in current neovim instance +keymap.set("n", "fh", "Telescope help_tags") -- list available help tags + +-- telescope git commands (not on youtube nvim video) +keymap.set("n", "gc", "Telescope git_commits") -- list all git commits (use to checkout) ["gc" for git commits] +keymap.set("n", "gfc", "Telescope git_bcommits") -- list git commits for current file/buffer (use to checkout) ["gfc" for git file commits] +keymap.set("n", "gb", "Telescope git_branches") -- list git branches (use to checkout) ["gb" for git branch] +keymap.set("n", "gs", "Telescope git_status") -- list current changes per file with diff preview ["gs" for git status] + +-- restart lsp server (not on youtube nvim video) +keymap.set("n", "rs", ":LspRestart") -- mapping to restart lsp if necessary diff --git a/.config/nvim/lua/josean/core/options.lua b/.config/nvim/lua/josean/core/options.lua new file mode 100644 index 0000000..1aac738 --- /dev/null +++ b/.config/nvim/lua/josean/core/options.lua @@ -0,0 +1,41 @@ +local opt = vim.opt -- for conciseness + +-- line numbers +opt.relativenumber = true -- show relative line numbers +opt.number = true -- shows absolute line number on cursor line (when relative number is on) + +-- tabs & indentation +opt.tabstop = 2 -- 2 spaces for tabs (prettier default) +opt.shiftwidth = 2 -- 2 spaces for indent width +opt.expandtab = true -- expand tab to spaces +opt.autoindent = true -- copy indent from current line when starting new one + +-- line wrapping +opt.wrap = false -- disable line wrapping + +-- search settings +opt.ignorecase = true -- ignore case when searching +opt.smartcase = true -- if you include mixed case in your search, assumes you want case-sensitive + +-- cursor line +opt.cursorline = true -- highlight the current cursor line + +-- appearance + +-- turn on termguicolors for nightfly colorscheme to work +-- (have to use iterm2 or any other true color terminal) +opt.termguicolors = true +opt.background = "dark" -- colorschemes that can be light or dark will be made dark +opt.signcolumn = "yes" -- show sign column so that text doesn't shift + +-- backspace +opt.backspace = "indent,eol,start" -- allow backspace on indent, end of line or insert mode start position + +-- clipboard +opt.clipboard:append("unnamedplus") -- use system clipboard as default register + +-- split windows +opt.splitright = true -- split vertical window to the right +opt.splitbelow = true -- split horizontal window to the bottom + +opt.iskeyword:append("-") -- consider string-string as whole word diff --git a/.config/nvim/lua/josean/plugins-setup.lua b/.config/nvim/lua/josean/plugins-setup.lua new file mode 100644 index 0000000..06fe20c --- /dev/null +++ b/.config/nvim/lua/josean/plugins-setup.lua @@ -0,0 +1,105 @@ +-- 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 +end +local packer_bootstrap = ensure_packer() -- true if packer was just installed + +-- autocommand that reloads neovim and installs/updates/removes plugins +-- when file is saved +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins-setup.lua source | PackerSync + augroup end +]]) + +-- import packer safely +local status, packer = pcall(require, "packer") +if not status then + return +end + +-- add list of plugins to install +return packer.startup(function(use) + -- packer can manage itself + use("wbthomason/packer.nvim") + + use("nvim-lua/plenary.nvim") -- lua functions that many plugins use + + use("bluz71/vim-nightfly-guicolors") -- preferred colorscheme + + use("christoomey/vim-tmux-navigator") -- tmux & split window navigation + + 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) + + -- commenting with gc + use("numToStr/Comment.nvim") + + -- file explorer + use("nvim-tree/nvim-tree.lua") + + -- vs-code like icons + use("kyazdani42/nvim-web-devicons") + + -- 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 + + -- 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 + + -- 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 + + -- 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, + }) + + -- auto closing + use("windwp/nvim-autopairs") -- autoclose parens, brackets, quotes, etc... + use("windwp/nvim-ts-autotag") -- autoclose tags + + -- git integration + use("lewis6991/gitsigns.nvim") + + 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 new file mode 100644 index 0000000..19890bb --- /dev/null +++ b/.config/nvim/lua/josean/plugins/autopairs.lua @@ -0,0 +1,30 @@ +-- import nvim-autopairs safely +local autopairs_setup, autopairs = pcall(require, "nvim-autopairs") +if not autopairs_setup then + 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 + }, +}) + +-- 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 +end + +-- import nvim-cmp plugin safely (completions plugin) +local cmp_setup, cmp = pcall(require, "cmp") +if not cmp_setup then + return +end + +-- make autopairs and completion work together +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) diff --git a/.config/nvim/lua/josean/plugins/comment.lua b/.config/nvim/lua/josean/plugins/comment.lua new file mode 100644 index 0000000..35a7640 --- /dev/null +++ b/.config/nvim/lua/josean/plugins/comment.lua @@ -0,0 +1,8 @@ +-- import comment plugin safely +local setup, comment = pcall(require, "Comment") +if not setup then + return +end + +-- enable comment +comment.setup() diff --git a/.config/nvim/lua/josean/plugins/gitsigns.lua b/.config/nvim/lua/josean/plugins/gitsigns.lua new file mode 100644 index 0000000..22f7ba6 --- /dev/null +++ b/.config/nvim/lua/josean/plugins/gitsigns.lua @@ -0,0 +1,8 @@ +-- import gitsigns plugin safely +local setup, gitsigns = pcall(require, "gitsigns") +if not setup then + return +end + +-- configure/enable gitsigns +gitsigns.setup() diff --git a/.config/nvim/lua/josean/plugins/lsp/lspconfig.lua b/.config/nvim/lua/josean/plugins/lsp/lspconfig.lua new file mode 100644 index 0000000..f124f73 --- /dev/null +++ b/.config/nvim/lua/josean/plugins/lsp/lspconfig.lua @@ -0,0 +1,102 @@ +-- import lspconfig plugin safely +local lspconfig_status, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status then + 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 +end + +-- import typescript plugin safely +local typescript_setup, typescript = pcall(require, "typescript") +if not typescript_setup then + 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 } + + -- 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") + end +end + +-- used to enable autocompletion (assign to every lsp server config) +local capabilities = cmp_nvim_lsp.default_capabilities() + +-- Change the Diagnostic symbols in the sign column (gutter) +-- (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 = "" }) +end + +-- configure html server +lspconfig["html"].setup({ + capabilities = capabilities, + on_attach = on_attach, +}) + +-- configure typescript server with plugin +typescript.setup({ + server = { + capabilities = capabilities, + on_attach = on_attach, + }, +}) + +-- configure css server +lspconfig["cssls"].setup({ + capabilities = capabilities, + on_attach = on_attach, +}) + +-- configure tailwindcss server +lspconfig["tailwindcss"].setup({ + 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, + }, + }, + }, + }, +}) diff --git a/.config/nvim/lua/josean/plugins/lsp/lspsaga.lua b/.config/nvim/lua/josean/plugins/lsp/lspsaga.lua new file mode 100644 index 0000000..8ef575c --- /dev/null +++ b/.config/nvim/lua/josean/plugins/lsp/lspsaga.lua @@ -0,0 +1,18 @@ +-- import lspsaga safely +local saga_status, saga = pcall(require, "lspsaga") +if not saga_status then + 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 = "", + }, +}) diff --git a/.config/nvim/lua/josean/plugins/lsp/mason.lua b/.config/nvim/lua/josean/plugins/lsp/mason.lua new file mode 100644 index 0000000..9d1ae0a --- /dev/null +++ b/.config/nvim/lua/josean/plugins/lsp/mason.lua @@ -0,0 +1,44 @@ +-- import mason plugin safely +local mason_status, mason = pcall(require, "mason") +if not mason_status then + return +end + +-- import mason-lspconfig plugin safely +local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig") +if not mason_lspconfig_status then + 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 +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 +}) + +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 servers (with lspconfig) + 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 new file mode 100644 index 0000000..bff4f20 --- /dev/null +++ b/.config/nvim/lua/josean/plugins/lsp/null-ls.lua @@ -0,0 +1,43 @@ +-- import null-ls plugin safely +local setup, null_ls = pcall(require, "null-ls") +if not setup then + return +end + +-- for conciseness +local formatting = null_ls.builtins.formatting -- to setup formatters +local diagnostics = null_ls.builtins.diagnostics -- to setup linters + +-- to setup format on save +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, -- js/ts linter + }, + -- 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 new file mode 100644 index 0000000..c3b54ab --- /dev/null +++ b/.config/nvim/lua/josean/plugins/lualine.lua @@ -0,0 +1,36 @@ +-- import lualine plugin safely +local status, lualine = pcall(require, "lualine") +if not status then + return +end + +-- get lualine nightfly theme +local lualine_nightfly = require("lualine.themes.nightfly") + +-- new colors for theme +local new_colors = { + blue = "#65D1FF", + green = "#3EFFDC", + violet = "#FF61EF", + yellow = "#FFDA7B", + black = "#000000", +} + +-- change nightlfy theme colors +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 + }, +} + +-- configure lualine with modified theme +lualine.setup({ + options = { + theme = lualine_nightfly, + }, +}) diff --git a/.config/nvim/lua/josean/plugins/nvim-cmp.lua b/.config/nvim/lua/josean/plugins/nvim-cmp.lua new file mode 100644 index 0000000..f38f474 --- /dev/null +++ b/.config/nvim/lua/josean/plugins/nvim-cmp.lua @@ -0,0 +1,82 @@ +-- import nvim-cmp plugin safely +local cmp_status, cmp = pcall(require, "cmp") +if not cmp_status then + return +end + +-- import luasnip plugin safely +local luasnip_status, luasnip = pcall(require, "luasnip") +if not luasnip_status then + return +end + +-- import lspkind plugin safely +local lspkind_status, lspkind = pcall(require, "lspkind") +if not lspkind_status then + return +end + +-- load vs-code like snippets from plugins (e.g. friendly-snippets) +require("luasnip/loaders/from_vscode").lazy_load() + +vim.opt.completeopt = "menu,menuone,noselect" + +-- helper function for super tab functionality (not in youtube nvim video) +local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +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 }), + + -- super tab functionality (not in youtube nvim video) + [""] = cmp.mapping(function(fallback) -- use tab for next suggestion + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) -- use shift-tab for prev suggestion + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + -- 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 new file mode 100644 index 0000000..e1e14e4 --- /dev/null +++ b/.config/nvim/lua/josean/plugins/nvim-tree.lua @@ -0,0 +1,37 @@ +-- import nvim-tree plugin safely +local setup, nvimtree = pcall(require, "nvim-tree") +if not setup then + return +end + +-- recommended settings from nvim-tree documentation +vim.g.loaded = 1 +vim.g.loaded_netrwPlugin = 1 + +-- change color for arrows in tree to light blue +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, + }, + }, + }, +}) diff --git a/.config/nvim/lua/josean/plugins/telescope.lua b/.config/nvim/lua/josean/plugins/telescope.lua new file mode 100644 index 0000000..a70a5e9 --- /dev/null +++ b/.config/nvim/lua/josean/plugins/telescope.lua @@ -0,0 +1,27 @@ +-- import telescope plugin safely +local telescope_setup, telescope = pcall(require, "telescope") +if not telescope_setup then + return +end + +-- import telescope actions safely +local actions_setup, actions = pcall(require, "telescope.actions") +if not actions_setup then + 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 + }, + }, + }, +}) + +telescope.load_extension("fzf") diff --git a/.config/nvim/lua/josean/plugins/treesitter.lua b/.config/nvim/lua/josean/plugins/treesitter.lua new file mode 100644 index 0000000..2c0a7d5 --- /dev/null +++ b/.config/nvim/lua/josean/plugins/treesitter.lua @@ -0,0 +1,37 @@ +-- import nvim-treesitter plugin safely +local status, treesitter = pcall(require, "nvim-treesitter.configs") +if not status then + 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, +})