mirror of
https://github.com/josean-dev/dev-environment-files.git
synced 2025-01-08 17:21:23 +01:00
Added nvim configuration
This commit is contained in:
parent
1caf4b482b
commit
e96d84407b
18 changed files with 743 additions and 0 deletions
44
.config/nvim/.gitignore
vendored
Normal file
44
.config/nvim/.gitignore
vendored
Normal file
|
@ -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
|
16
.config/nvim/init.lua
Normal file
16
.config/nvim/init.lua
Normal file
|
@ -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")
|
7
.config/nvim/lua/josean/core/colorscheme.lua
Normal file
7
.config/nvim/lua/josean/core/colorscheme.lua
Normal file
|
@ -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
|
58
.config/nvim/lua/josean/core/keymaps.lua
Normal file
58
.config/nvim/lua/josean/core/keymaps.lua
Normal file
|
@ -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", "<ESC>")
|
||||||
|
|
||||||
|
-- clear search highlights
|
||||||
|
keymap.set("n", "<leader>nh", ":nohl<CR>")
|
||||||
|
|
||||||
|
-- delete single character without copying into register
|
||||||
|
keymap.set("n", "x", '"_x')
|
||||||
|
|
||||||
|
-- increment/decrement numbers
|
||||||
|
keymap.set("n", "<leader>+", "<C-a>")
|
||||||
|
keymap.set("n", "<leader>-", "<C-x>")
|
||||||
|
|
||||||
|
-- window management
|
||||||
|
keymap.set("n", "<leader>sv", "<C-w>v") -- split window vertically
|
||||||
|
keymap.set("n", "<leader>sh", "<C-w>s") -- split window horizontally
|
||||||
|
keymap.set("n", "<leader>se", "<C-w>=") -- make split windows equal width & height
|
||||||
|
keymap.set("n", "<leader>sx", ":close<CR>") -- close current split window
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>to", ":tabnew<CR>") -- open new tab
|
||||||
|
keymap.set("n", "<leader>tx", ":tabclose<CR>") -- close current tab
|
||||||
|
keymap.set("n", "<leader>tn", ":tabn<CR>") -- go to next tab
|
||||||
|
keymap.set("n", "<leader>tp", ":tabp<CR>") -- go to previous tab
|
||||||
|
|
||||||
|
----------------------
|
||||||
|
-- Plugin Keybinds
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
-- vim-maximizer
|
||||||
|
keymap.set("n", "<leader>sm", ":MaximizerToggle<CR>") -- toggle split window maximization
|
||||||
|
|
||||||
|
-- nvim-tree
|
||||||
|
keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>") -- toggle file explorer
|
||||||
|
|
||||||
|
-- telescope
|
||||||
|
keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>") -- find files within current working directory, respects .gitignore
|
||||||
|
keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>") -- find string in current working directory as you type
|
||||||
|
keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>") -- find string under cursor in current working directory
|
||||||
|
keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>") -- list open buffers in current neovim instance
|
||||||
|
keymap.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>") -- list available help tags
|
||||||
|
|
||||||
|
-- telescope git commands (not on youtube nvim video)
|
||||||
|
keymap.set("n", "<leader>gc", "<cmd>Telescope git_commits<cr>") -- list all git commits (use <cr> to checkout) ["gc" for git commits]
|
||||||
|
keymap.set("n", "<leader>gfc", "<cmd>Telescope git_bcommits<cr>") -- list git commits for current file/buffer (use <cr> to checkout) ["gfc" for git file commits]
|
||||||
|
keymap.set("n", "<leader>gb", "<cmd>Telescope git_branches<cr>") -- list git branches (use <cr> to checkout) ["gb" for git branch]
|
||||||
|
keymap.set("n", "<leader>gs", "<cmd>Telescope git_status<cr>") -- list current changes per file with diff preview ["gs" for git status]
|
||||||
|
|
||||||
|
-- restart lsp server (not on youtube nvim video)
|
||||||
|
keymap.set("n", "<leader>rs", ":LspRestart<CR>") -- mapping to restart lsp if necessary
|
41
.config/nvim/lua/josean/core/options.lua
Normal file
41
.config/nvim/lua/josean/core/options.lua
Normal file
|
@ -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
|
105
.config/nvim/lua/josean/plugins-setup.lua
Normal file
105
.config/nvim/lua/josean/plugins-setup.lua
Normal file
|
@ -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 <afile> | 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)
|
30
.config/nvim/lua/josean/plugins/autopairs.lua
Normal file
30
.config/nvim/lua/josean/plugins/autopairs.lua
Normal file
|
@ -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())
|
8
.config/nvim/lua/josean/plugins/comment.lua
Normal file
8
.config/nvim/lua/josean/plugins/comment.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-- import comment plugin safely
|
||||||
|
local setup, comment = pcall(require, "Comment")
|
||||||
|
if not setup then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- enable comment
|
||||||
|
comment.setup()
|
8
.config/nvim/lua/josean/plugins/gitsigns.lua
Normal file
8
.config/nvim/lua/josean/plugins/gitsigns.lua
Normal file
|
@ -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()
|
102
.config/nvim/lua/josean/plugins/lsp/lspconfig.lua
Normal file
102
.config/nvim/lua/josean/plugins/lsp/lspconfig.lua
Normal file
|
@ -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", "<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>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", "<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>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", "[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", "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
|
||||||
|
|
||||||
|
-- typescript specific keymaps (e.g. rename file and update imports)
|
||||||
|
if client.name == "tsserver" then
|
||||||
|
keymap.set("n", "<leader>rf", ":TypescriptRenameFile<CR>")
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
18
.config/nvim/lua/josean/plugins/lsp/lspsaga.lua
Normal file
18
.config/nvim/lua/josean/plugins/lsp/lspsaga.lua
Normal file
|
@ -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 = "<C-k>", next = "<C-j>" },
|
||||||
|
-- use enter to open file with finder
|
||||||
|
finder_action_keys = {
|
||||||
|
open = "<CR>",
|
||||||
|
},
|
||||||
|
-- use enter to open file with definition preview
|
||||||
|
definition_action_keys = {
|
||||||
|
edit = "<CR>",
|
||||||
|
},
|
||||||
|
})
|
44
.config/nvim/lua/josean/plugins/lsp/mason.lua
Normal file
44
.config/nvim/lua/josean/plugins/lsp/mason.lua
Normal file
|
@ -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,
|
||||||
|
})
|
43
.config/nvim/lua/josean/plugins/lsp/null-ls.lua
Normal file
43
.config/nvim/lua/josean/plugins/lsp/null-ls.lua
Normal file
|
@ -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,
|
||||||
|
})
|
36
.config/nvim/lua/josean/plugins/lualine.lua
Normal file
36
.config/nvim/lua/josean/plugins/lualine.lua
Normal file
|
@ -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,
|
||||||
|
},
|
||||||
|
})
|
82
.config/nvim/lua/josean/plugins/nvim-cmp.lua
Normal file
82
.config/nvim/lua/josean/plugins/nvim-cmp.lua
Normal file
|
@ -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({
|
||||||
|
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
|
||||||
|
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
|
||||||
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||||
|
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||||
|
|
||||||
|
-- super tab functionality (not in youtube nvim video)
|
||||||
|
["<Tab>"] = 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" }),
|
||||||
|
|
||||||
|
["<S-Tab>"] = 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 = "...",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
37
.config/nvim/lua/josean/plugins/nvim-tree.lua
Normal file
37
.config/nvim/lua/josean/plugins/nvim-tree.lua
Normal file
|
@ -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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
27
.config/nvim/lua/josean/plugins/telescope.lua
Normal file
27
.config/nvim/lua/josean/plugins/telescope.lua
Normal file
|
@ -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 = {
|
||||||
|
["<C-k>"] = actions.move_selection_previous, -- move to prev 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
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
telescope.load_extension("fzf")
|
37
.config/nvim/lua/josean/plugins/treesitter.lua
Normal file
37
.config/nvim/lua/josean/plugins/treesitter.lua
Normal file
|
@ -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,
|
||||||
|
})
|
Loading…
Reference in a new issue