Added stylua formatting config to use 2 spaces for tabs

This commit is contained in:
josean-dev 2022-11-05 17:13:18 -04:00
parent 0b28e667ea
commit 387cb96e64
15 changed files with 305 additions and 303 deletions

View file

@ -0,0 +1,2 @@
indent_type = "Spaces"
indent_width = 2

View file

@ -2,6 +2,6 @@
-- in case it isn't installed -- in case it isn't installed
local status, _ = pcall(vim.cmd, "colorscheme nightfly") local status, _ = pcall(vim.cmd, "colorscheme nightfly")
if not status then if not status then
print("Colorscheme not found!") -- print error if colorscheme not installed print("Colorscheme not found!") -- print error if colorscheme not installed
return return
end end

View file

@ -1,13 +1,13 @@
-- auto install packer if not installed -- auto install packer if not installed
local ensure_packer = function() local ensure_packer = function()
local fn = vim.fn local fn = vim.fn
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
vim.cmd([[packadd packer.nvim]]) vim.cmd([[packadd packer.nvim]])
return true return true
end end
return false return false
end end
local packer_bootstrap = ensure_packer() -- true if packer was just installed local packer_bootstrap = ensure_packer() -- true if packer was just installed
@ -23,83 +23,83 @@ vim.cmd([[
-- import packer safely -- import packer safely
local status, packer = pcall(require, "packer") local status, packer = pcall(require, "packer")
if not status then if not status then
return return
end end
-- add list of plugins to install -- add list of plugins to install
return packer.startup(function(use) return packer.startup(function(use)
-- packer can manage itself -- packer can manage itself
use("wbthomason/packer.nvim") 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 -- essential plugins
use("tpope/vim-surround") -- add, delete, change surroundings (it's awesome) use("tpope/vim-surround") -- add, delete, change surroundings (it's awesome)
use("vim-scripts/ReplaceWithRegister") -- replace with register contents using motion (gr + motion) use("vim-scripts/ReplaceWithRegister") -- replace with register contents using motion (gr + motion)
-- commenting with gc -- commenting with gc
use("numToStr/Comment.nvim") use("numToStr/Comment.nvim")
-- file explorer -- file explorer
use("nvim-tree/nvim-tree.lua") use("nvim-tree/nvim-tree.lua")
-- vs-code like icons -- vs-code like icons
use("kyazdani42/nvim-web-devicons") use("kyazdani42/nvim-web-devicons")
-- statusline -- statusline
use("nvim-lualine/lualine.nvim") use("nvim-lualine/lualine.nvim")
-- fuzzy finding w/ telescope -- fuzzy finding w/ telescope
use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- dependency for better sorting performance 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 use({ "nvim-telescope/telescope.nvim", branch = "0.1.x" }) -- fuzzy finder
-- autocompletion -- autocompletion
use("hrsh7th/nvim-cmp") -- completion plugin use("hrsh7th/nvim-cmp") -- completion plugin
use("hrsh7th/cmp-buffer") -- source for text in buffer use("hrsh7th/cmp-buffer") -- source for text in buffer
use("hrsh7th/cmp-path") -- source for file system paths use("hrsh7th/cmp-path") -- source for file system paths
-- snippets -- snippets
use("L3MON4D3/LuaSnip") -- snippet engine use("L3MON4D3/LuaSnip") -- snippet engine
use("saadparwaiz1/cmp_luasnip") -- for autocompletion use("saadparwaiz1/cmp_luasnip") -- for autocompletion
use("rafamadriz/friendly-snippets") -- useful snippets use("rafamadriz/friendly-snippets") -- useful snippets
-- managing & installing lsp servers, linters & formatters -- managing & installing lsp servers, linters & formatters
use("williamboman/mason.nvim") -- in charge of managing 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 use("williamboman/mason-lspconfig.nvim") -- bridges gap b/w mason & lspconfig
-- configuring lsp servers -- configuring lsp servers
use("neovim/nvim-lspconfig") -- easily configure language servers use("neovim/nvim-lspconfig") -- easily configure language servers
use("hrsh7th/cmp-nvim-lsp") -- for autocompletion use("hrsh7th/cmp-nvim-lsp") -- for autocompletion
use({ "glepnir/lspsaga.nvim", branch = "main" }) -- enhanced lsp uis 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("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 use("onsails/lspkind.nvim") -- vs-code like icons for autocompletion
-- formatting & linting -- formatting & linting
use("jose-elias-alvarez/null-ls.nvim") -- configure formatters & linters use("jose-elias-alvarez/null-ls.nvim") -- configure formatters & linters
use("jayp0521/mason-null-ls.nvim") -- bridges gap b/w mason & null-ls use("jayp0521/mason-null-ls.nvim") -- bridges gap b/w mason & null-ls
-- treesitter configuration -- treesitter configuration
use({ use({
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
run = function() run = function()
require("nvim-treesitter.install").update({ with_sync = true }) require("nvim-treesitter.install").update({ with_sync = true })
end, end,
}) })
-- auto closing -- auto closing
use("windwp/nvim-autopairs") -- autoclose parens, brackets, quotes, etc... use("windwp/nvim-autopairs") -- autoclose parens, brackets, quotes, etc...
use({ "windwp/nvim-ts-autotag", after = "nvim-treesitter" }) -- autoclose tags use({ "windwp/nvim-ts-autotag", after = "nvim-treesitter" }) -- autoclose tags
-- git integration -- git integration
use("lewis6991/gitsigns.nvim") -- show line modifications on left hand side use("lewis6991/gitsigns.nvim") -- show line modifications on left hand side
if packer_bootstrap then if packer_bootstrap then
require("packer").sync() require("packer").sync()
end end
end) end)

View file

@ -1,29 +1,29 @@
-- import nvim-autopairs safely -- import nvim-autopairs safely
local autopairs_setup, autopairs = pcall(require, "nvim-autopairs") local autopairs_setup, autopairs = pcall(require, "nvim-autopairs")
if not autopairs_setup then if not autopairs_setup then
return return
end end
-- configure autopairs -- configure autopairs
autopairs.setup({ autopairs.setup({
check_ts = true, -- enable treesitter check_ts = true, -- enable treesitter
ts_config = { ts_config = {
lua = { "string" }, -- don't add pairs in lua string treesitter nodes lua = { "string" }, -- don't add pairs in lua string treesitter nodes
javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes
java = false, -- don't check treesitter on java java = false, -- don't check treesitter on java
}, },
}) })
-- import nvim-autopairs completion functionality safely -- import nvim-autopairs completion functionality safely
local cmp_autopairs_setup, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp") local cmp_autopairs_setup, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp")
if not cmp_autopairs_setup then if not cmp_autopairs_setup then
return return
end end
-- import nvim-cmp plugin safely (completions plugin) -- import nvim-cmp plugin safely (completions plugin)
local cmp_setup, cmp = pcall(require, "cmp") local cmp_setup, cmp = pcall(require, "cmp")
if not cmp_setup then if not cmp_setup then
return return
end end
-- make autopairs and completion work together -- make autopairs and completion work together

View file

@ -1,7 +1,7 @@
-- import comment plugin safely -- import comment plugin safely
local setup, comment = pcall(require, "Comment") local setup, comment = pcall(require, "Comment")
if not setup then if not setup then
return return
end end
-- enable comment -- enable comment

View file

@ -1,7 +1,7 @@
-- import gitsigns plugin safely -- import gitsigns plugin safely
local setup, gitsigns = pcall(require, "gitsigns") local setup, gitsigns = pcall(require, "gitsigns")
if not setup then if not setup then
return return
end end
-- configure/enable gitsigns -- configure/enable gitsigns

View file

@ -1,48 +1,48 @@
-- import lspconfig plugin safely -- import lspconfig plugin safely
local lspconfig_status, lspconfig = pcall(require, "lspconfig") local lspconfig_status, lspconfig = pcall(require, "lspconfig")
if not lspconfig_status then if not lspconfig_status then
return return
end end
-- import cmp-nvim-lsp plugin safely -- import cmp-nvim-lsp plugin safely
local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not cmp_nvim_lsp_status then if not cmp_nvim_lsp_status then
return return
end end
-- import typescript plugin safely -- import typescript plugin safely
local typescript_setup, typescript = pcall(require, "typescript") local typescript_setup, typescript = pcall(require, "typescript")
if not typescript_setup then if not typescript_setup then
return return
end end
local keymap = vim.keymap -- for conciseness local keymap = vim.keymap -- for conciseness
-- enable keybinds only for when lsp server available -- enable keybinds only for when lsp server available
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
-- keybind options -- keybind options
local opts = { noremap = true, silent = true, buffer = bufnr } local opts = { noremap = true, silent = true, buffer = bufnr }
-- set keybinds -- set keybinds
keymap.set("n", "gf", "<cmd>Lspsaga lsp_finder<CR>", opts) -- show definition, references keymap.set("n", "gf", "<cmd>Lspsaga lsp_finder<CR>", opts) -- show definition, references
keymap.set("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts) -- got to declaration keymap.set("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts) -- got to declaration
keymap.set("n", "gd", "<cmd>Lspsaga peek_definition<CR>", opts) -- see definition and make edits in window keymap.set("n", "gd", "<cmd>Lspsaga peek_definition<CR>", opts) -- see definition and make edits in window
keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) -- go to implementation keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) -- go to implementation
keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", opts) -- see available code actions keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", opts) -- see available code actions
keymap.set("n", "<leader>rn", "<cmd>Lspsaga rename<CR>", opts) -- smart rename keymap.set("n", "<leader>rn", "<cmd>Lspsaga rename<CR>", opts) -- smart rename
keymap.set("n", "<leader>d", "<cmd>Lspsaga show_line_diagnostics<CR>", opts) -- show diagnostics for line keymap.set("n", "<leader>d", "<cmd>Lspsaga show_line_diagnostics<CR>", opts) -- show diagnostics for line
keymap.set("n", "<leader>d", "<cmd>Lspsaga show_cursor_diagnostics<CR>", opts) -- show diagnostics for cursor keymap.set("n", "<leader>d", "<cmd>Lspsaga show_cursor_diagnostics<CR>", opts) -- show diagnostics for cursor
keymap.set("n", "[d", "<cmd>Lspsaga diagnostic_jump_prev<CR>", opts) -- jump to previous diagnostic in buffer keymap.set("n", "[d", "<cmd>Lspsaga diagnostic_jump_prev<CR>", opts) -- jump to previous diagnostic in buffer
keymap.set("n", "]d", "<cmd>Lspsaga diagnostic_jump_next<CR>", opts) -- jump to next diagnostic in buffer keymap.set("n", "]d", "<cmd>Lspsaga diagnostic_jump_next<CR>", opts) -- jump to next diagnostic in buffer
keymap.set("n", "K", "<cmd>Lspsaga hover_doc<CR>", opts) -- show documentation for what is under cursor keymap.set("n", "K", "<cmd>Lspsaga hover_doc<CR>", opts) -- show documentation for what is under cursor
keymap.set("n", "<leader>o", "<cmd>LSoutlineToggle<CR>", opts) -- see outline on right hand side keymap.set("n", "<leader>o", "<cmd>LSoutlineToggle<CR>", opts) -- see outline on right hand side
-- typescript specific keymaps (e.g. rename file and update imports) -- typescript specific keymaps (e.g. rename file and update imports)
if client.name == "tsserver" then if client.name == "tsserver" then
keymap.set("n", "<leader>rf", ":TypescriptRenameFile<CR>") -- rename file and update imports keymap.set("n", "<leader>rf", ":TypescriptRenameFile<CR>") -- rename file and update imports
keymap.set("n", "<leader>oi", ":TypescriptOrganizeImports<CR>") -- organize imports (not in youtube nvim video) keymap.set("n", "<leader>oi", ":TypescriptOrganizeImports<CR>") -- organize imports (not in youtube nvim video)
keymap.set("n", "<leader>ru", ":TypescriptRemoveUnused<CR>") -- remove unused variables (not in youtube nvim video) keymap.set("n", "<leader>ru", ":TypescriptRemoveUnused<CR>") -- remove unused variables (not in youtube nvim video)
end end
end end
-- used to enable autocompletion (assign to every lsp server config) -- 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) -- (not in youtube nvim video)
local signs = { Error = "", Warn = "", Hint = "", Info = "" } local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end end
-- configure html server -- configure html server
lspconfig["html"].setup({ lspconfig["html"].setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
}) })
-- configure typescript server with plugin -- configure typescript server with plugin
typescript.setup({ typescript.setup({
server = { server = {
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
}, },
}) })
-- configure css server -- configure css server
lspconfig["cssls"].setup({ lspconfig["cssls"].setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
}) })
-- configure tailwindcss server -- configure tailwindcss server
lspconfig["tailwindcss"].setup({ lspconfig["tailwindcss"].setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
}) })
-- configure lua server (with special settings) -- configure lua server (with special settings)
lspconfig["sumneko_lua"].setup({ lspconfig["sumneko_lua"].setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
settings = { -- custom settings for lua settings = { -- custom settings for lua
Lua = { Lua = {
-- make the language server recognize "vim" global -- make the language server recognize "vim" global
diagnostics = { diagnostics = {
globals = { "vim" }, globals = { "vim" },
}, },
workspace = { workspace = {
-- make language server aware of runtime files -- make language server aware of runtime files
library = { library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true, [vim.fn.stdpath("config") .. "/lua"] = true,
}, },
}, },
}, },
}, },
}) })

View file

@ -1,18 +1,18 @@
-- import lspsaga safely -- import lspsaga safely
local saga_status, saga = pcall(require, "lspsaga") local saga_status, saga = pcall(require, "lspsaga")
if not saga_status then if not saga_status then
return return
end end
saga.init_lsp_saga({ saga.init_lsp_saga({
-- keybinds for navigation in lspsaga window -- keybinds for navigation in lspsaga window
move_in_saga = { prev = "<C-k>", next = "<C-j>" }, move_in_saga = { prev = "<C-k>", next = "<C-j>" },
-- use enter to open file with finder -- use enter to open file with finder
finder_action_keys = { finder_action_keys = {
open = "<CR>", open = "<CR>",
}, },
-- use enter to open file with definition preview -- use enter to open file with definition preview
definition_action_keys = { definition_action_keys = {
edit = "<CR>", edit = "<CR>",
}, },
}) })

View file

@ -1,44 +1,44 @@
-- import mason plugin safely -- import mason plugin safely
local mason_status, mason = pcall(require, "mason") local mason_status, mason = pcall(require, "mason")
if not mason_status then if not mason_status then
return return
end end
-- import mason-lspconfig plugin safely -- import mason-lspconfig plugin safely
local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig") local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig")
if not mason_lspconfig_status then if not mason_lspconfig_status then
return return
end end
-- import mason-null-ls plugin safely -- import mason-null-ls plugin safely
local mason_null_ls_status, mason_null_ls = pcall(require, "mason-null-ls") local mason_null_ls_status, mason_null_ls = pcall(require, "mason-null-ls")
if not mason_null_ls_status then if not mason_null_ls_status then
return return
end end
-- enable mason -- enable mason
mason.setup() mason.setup()
mason_lspconfig.setup({ mason_lspconfig.setup({
-- list of servers for mason to install -- list of servers for mason to install
ensure_installed = { ensure_installed = {
"tsserver", "tsserver",
"html", "html",
"cssls", "cssls",
"tailwindcss", "tailwindcss",
"sumneko_lua", "sumneko_lua",
}, },
-- auto-install configured servers (with lspconfig) -- auto-install configured servers (with lspconfig)
automatic_installation = true, -- not the same as ensure_installed automatic_installation = true, -- not the same as ensure_installed
}) })
mason_null_ls.setup({ mason_null_ls.setup({
-- list of formatters & linters for mason to install -- list of formatters & linters for mason to install
ensure_installed = { ensure_installed = {
"prettier", -- ts/js formatter "prettier", -- ts/js formatter
"stylua", -- lua formatter "stylua", -- lua formatter
"eslint_d", -- ts/js linter "eslint_d", -- ts/js linter
}, },
-- auto-install configured formatters & linters (with null-ls) -- auto-install configured formatters & linters (with null-ls)
automatic_installation = true, automatic_installation = true,
}) })

View file

@ -1,7 +1,7 @@
-- import null-ls plugin safely -- import null-ls plugin safely
local setup, null_ls = pcall(require, "null-ls") local setup, null_ls = pcall(require, "null-ls")
if not setup then if not setup then
return return
end end
-- for conciseness -- for conciseness
@ -13,36 +13,36 @@ local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
-- configure null_ls -- configure null_ls
null_ls.setup({ null_ls.setup({
-- setup formatters & linters -- setup formatters & linters
sources = { sources = {
-- to disable file types use -- to disable file types use
-- "formatting.prettier.with({disabled_filetypes: {}})" (see null-ls docs) -- "formatting.prettier.with({disabled_filetypes: {}})" (see null-ls docs)
formatting.prettier, -- js/ts formatter formatting.prettier, -- js/ts formatter
formatting.stylua, -- lua formatter formatting.stylua, -- lua formatter
diagnostics.eslint_d.with({ -- js/ts linter diagnostics.eslint_d.with({ -- js/ts linter
-- only enable eslint if root has .eslintrc.js (not in youtube nvim video) -- only enable eslint if root has .eslintrc.js (not in youtube nvim video)
condition = function(utils) condition = function(utils)
return utils.root_has_file(".eslintrc.js") -- change file extension if you use something else return utils.root_has_file(".eslintrc.js") -- change file extension if you use something else
end, end,
}), }),
}, },
-- configure format on save -- configure format on save
on_attach = function(current_client, bufnr) on_attach = function(current_client, bufnr)
if current_client.supports_method("textDocument/formatting") then if current_client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", { vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup, group = augroup,
buffer = bufnr, buffer = bufnr,
callback = function() callback = function()
vim.lsp.buf.format({ vim.lsp.buf.format({
filter = function(client) filter = function(client)
-- only use null-ls for formatting instead of lsp server -- only use null-ls for formatting instead of lsp server
return client.name == "null-ls" return client.name == "null-ls"
end, end,
bufnr = bufnr, bufnr = bufnr,
}) })
end, end,
}) })
end end
end, end,
}) })

View file

@ -1,7 +1,7 @@
-- import lualine plugin safely -- import lualine plugin safely
local status, lualine = pcall(require, "lualine") local status, lualine = pcall(require, "lualine")
if not status then if not status then
return return
end end
-- get lualine nightfly theme -- get lualine nightfly theme
@ -9,11 +9,11 @@ local lualine_nightfly = require("lualine.themes.nightfly")
-- new colors for theme -- new colors for theme
local new_colors = { local new_colors = {
blue = "#65D1FF", blue = "#65D1FF",
green = "#3EFFDC", green = "#3EFFDC",
violet = "#FF61EF", violet = "#FF61EF",
yellow = "#FFDA7B", yellow = "#FFDA7B",
black = "#000000", black = "#000000",
} }
-- change nightlfy theme colors -- 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.insert.a.bg = new_colors.green
lualine_nightfly.visual.a.bg = new_colors.violet lualine_nightfly.visual.a.bg = new_colors.violet
lualine_nightfly.command = { lualine_nightfly.command = {
a = { a = {
gui = "bold", gui = "bold",
bg = new_colors.yellow, bg = new_colors.yellow,
fg = new_colors.black, -- black fg = new_colors.black, -- black
}, },
} }
-- configure lualine with modified theme -- configure lualine with modified theme
lualine.setup({ lualine.setup({
options = { options = {
theme = lualine_nightfly, theme = lualine_nightfly,
}, },
}) })

View file

@ -1,19 +1,19 @@
-- import nvim-cmp plugin safely -- import nvim-cmp plugin safely
local cmp_status, cmp = pcall(require, "cmp") local cmp_status, cmp = pcall(require, "cmp")
if not cmp_status then if not cmp_status then
return return
end end
-- import luasnip plugin safely -- import luasnip plugin safely
local luasnip_status, luasnip = pcall(require, "luasnip") local luasnip_status, luasnip = pcall(require, "luasnip")
if not luasnip_status then if not luasnip_status then
return return
end end
-- import lspkind plugin safely -- import lspkind plugin safely
local lspkind_status, lspkind = pcall(require, "lspkind") local lspkind_status, lspkind = pcall(require, "lspkind")
if not lspkind_status then if not lspkind_status then
return return
end end
-- load vs-code like snippets from plugins (e.g. friendly-snippets) -- 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" vim.opt.completeopt = "menu,menuone,noselect"
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) luasnip.lsp_expand(args.body)
end, end,
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion ["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion ["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions ["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
["<C-e>"] = cmp.mapping.abort(), -- close completion window ["<C-e>"] = cmp.mapping.abort(), -- close completion window
["<CR>"] = cmp.mapping.confirm({ select = false }), ["<CR>"] = cmp.mapping.confirm({ select = false }),
}), }),
-- sources for autocompletion -- sources for autocompletion
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, -- lsp { name = "nvim_lsp" }, -- lsp
{ name = "luasnip" }, -- snippets { name = "luasnip" }, -- snippets
{ name = "buffer" }, -- text within current buffer { name = "buffer" }, -- text within current buffer
{ name = "path" }, -- file system paths { name = "path" }, -- file system paths
}), }),
-- configure lspkind for vs-code like icons -- configure lspkind for vs-code like icons
formatting = { formatting = {
format = lspkind.cmp_format({ format = lspkind.cmp_format({
maxwidth = 50, maxwidth = 50,
ellipsis_char = "...", ellipsis_char = "...",
}), }),
}, },
}) })

View file

@ -1,7 +1,7 @@
-- import nvim-tree plugin safely -- import nvim-tree plugin safely
local setup, nvimtree = pcall(require, "nvim-tree") local setup, nvimtree = pcall(require, "nvim-tree")
if not setup then if not setup then
return return
end end
-- recommended settings from nvim-tree documentation -- recommended settings from nvim-tree documentation
@ -13,25 +13,25 @@ vim.cmd([[ highlight NvimTreeIndentMarker guifg=#3FC5FF ]])
-- configure nvim-tree -- configure nvim-tree
nvimtree.setup({ nvimtree.setup({
-- change folder arrow icons -- change folder arrow icons
renderer = { renderer = {
icons = { icons = {
glyphs = { glyphs = {
folder = { folder = {
arrow_closed = "", -- arrow when folder is closed arrow_closed = "", -- arrow when folder is closed
arrow_open = "", -- arrow when folder is open arrow_open = "", -- arrow when folder is open
}, },
}, },
}, },
}, },
-- disable window_picker for -- disable window_picker for
-- explorer to work well with -- explorer to work well with
-- window splits -- window splits
actions = { actions = {
open_file = { open_file = {
window_picker = { window_picker = {
enable = false, enable = false,
}, },
}, },
}, },
}) })

View file

@ -1,27 +1,27 @@
-- import telescope plugin safely -- import telescope plugin safely
local telescope_setup, telescope = pcall(require, "telescope") local telescope_setup, telescope = pcall(require, "telescope")
if not telescope_setup then if not telescope_setup then
return return
end end
-- import telescope actions safely -- import telescope actions safely
local actions_setup, actions = pcall(require, "telescope.actions") local actions_setup, actions = pcall(require, "telescope.actions")
if not actions_setup then if not actions_setup then
return return
end end
-- configure telescope -- configure telescope
telescope.setup({ telescope.setup({
-- configure custom mappings -- configure custom mappings
defaults = { defaults = {
mappings = { mappings = {
i = { i = {
["<C-k>"] = actions.move_selection_previous, -- move to prev result ["<C-k>"] = actions.move_selection_previous, -- move to prev result
["<C-j>"] = actions.move_selection_next, -- move to next result ["<C-j>"] = actions.move_selection_next, -- move to next result
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist, -- send selected to quickfixlist ["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist, -- send selected to quickfixlist
}, },
}, },
}, },
}) })
telescope.load_extension("fzf") telescope.load_extension("fzf")

View file

@ -1,37 +1,37 @@
-- import nvim-treesitter plugin safely -- import nvim-treesitter plugin safely
local status, treesitter = pcall(require, "nvim-treesitter.configs") local status, treesitter = pcall(require, "nvim-treesitter.configs")
if not status then if not status then
return return
end end
-- configure treesitter -- configure treesitter
treesitter.setup({ treesitter.setup({
-- enable syntax highlighting -- enable syntax highlighting
highlight = { highlight = {
enable = true, enable = true,
}, },
-- enable indentation -- enable indentation
indent = { enable = true }, indent = { enable = true },
-- enable autotagging (w/ nvim-ts-autotag plugin) -- enable autotagging (w/ nvim-ts-autotag plugin)
autotag = { enable = true }, autotag = { enable = true },
-- ensure these language parsers are installed -- ensure these language parsers are installed
ensure_installed = { ensure_installed = {
"json", "json",
"javascript", "javascript",
"typescript", "typescript",
"tsx", "tsx",
"yaml", "yaml",
"html", "html",
"css", "css",
"markdown", "markdown",
"svelte", "svelte",
"graphql", "graphql",
"bash", "bash",
"lua", "lua",
"vim", "vim",
"dockerfile", "dockerfile",
"gitignore", "gitignore",
}, },
-- auto install above language parsers -- auto install above language parsers
auto_install = true, auto_install = true,
}) })