Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nvim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require("plugins-setup")
require("core/options")
require("core/keymaps")
require("core/colorscheme")
require("plugins/comment")
require("plugins/nvim-tree")
require("plugins/lualine")
8 changes: 8 additions & 0 deletions nvim/lua/core/colorscheme.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- set colorscheme to nightfly with protected call
-- in case it isn't installed
local status, _ = pcall(vim.cmd, "colorscheme tokyonight-night")
if not status then
print("Colorscheme not found!") -- print error if colorscheme not installed
return
end

56 changes: 56 additions & 0 deletions nvim/lua/core/keymaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- comma as leader key
vim.g.mapleader = ','

local map = vim.keymap.set

map('n', ';', ':', { noremap=true })

-- splits
-- moving
map({'n','c'}, '<C-H>', '<C-W><C-H>', { noremap=true })
map({'n','c'}, '<C-J>', '<C-W><C-J>', { noremap=true })
map({'n','c'}, '<C-K>', '<C-W><C-K>', { noremap=true })
map({'n','c'}, '<C-L>', '<C-W><C-L>', { noremap=true })
-- terminal management
map('n', '<leader>vt', ':vertical terminal')
map('c', 'vt', ':vertical terminal', { noremap=true })
map('n', '<leader>ht', ':terminal')
map('c', 'ht', ':terminal', { noremap=true })
-- window management
map("n", "<leader>sv", "<C-w>v") -- split window vertically
map("n", "<leader>sh", "<C-w>s") -- split window horizontally
map("n", "<leader>se", "<C-w>=") -- make split windows equal width & height
map("n", "<leader>sx", ":close<CR>") -- close current split window

-- TODO: buffer managment

-- clear search highlighting
map('n', '<leader><space>', ':noh<CR>', { noremap=true })

-- match bracket pairs
map({'n','v'}, '<tab>', '%', { noremap=true })
-- set list and listchars
map('n', '<leader>l', ':set list!<CR>')
-- toggle paste and nopaste
map('n', '<leader>p', ':set paste!<CR>')

-- sudo save
map('c', 'w!!', 'w !sudo tee > /dev/null %')

-- gf is built in and will "start editing the file whose name is under the cursor
-- gb is not built in and will "Go back to the file which you came from
map('n', 'gb', '<C-o>', { noremap=true })

-- insert a 'search and replace' command where the word under the cursor is being replaced
--map('n', '<leader>s', ':%s/\<<C-r><C-w>\>//g<Left><Left>' { noremap=true }

-- x does not copy character into register
map('n', 'x', '"_x')

-- keymaps for plugins

-- vim-maximizer
map('n', '<leader>sm', ':MaximizerToggle<CR>')

-- nvim-tree
map('n', '<leader>e', ':NvimTreeToggle<CR>')
80 changes: 80 additions & 0 deletions nvim/lua/core/options.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
local opt = vim.opt -- global option
local wo = vim.wo -- buffer-local option
local bo = vim.bo -- window-local option
local g = vim.g
local cmd = vim.cmd


-- misc
opt.swapfile = true
opt.hidden = true --buffers
opt.backup = false -- no file backups
opt.encoding = 'utf8'
opt.writebackup = false
-- cmd('syntax on')
-- default opt.backspace = 'indent,eol,start'

-- line numbers
opt.number = true
opt.relativenumber = true
cmd [[
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
]]

-- cursor
opt.cursorline = true
opt.ruler = true -- cursor

-- line wrapping
opt.wrap = false

-- searching
opt.ignorecase = true
opt.smartcase = true
opt.showmatch = true

-- appearance
opt.termguicolors = true
opt.background = 'dark'
opt.signcolumn = "yes"
opt.scrolloff = 6

-- status bar
opt.showcmd = true
opt.showmode = false

-- mouse
opt.mousehide = true -- hide mouse when typing
opt.selectmode = 'mouse' -- select text with mouse

-- splits
opt.splitbelow = true
opt.splitright = true

-- see tabs, spaces, eol (keymap is '<leader>l')
opt.listchars = 'eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣'

-- tab
opt.expandtab = true
opt.tabstop = 4
opt.shiftwidth = 4
opt.softtabstop = 4
opt.textwidth = 0
--[[
" tab-settings for specific filetypes
autocmd FileType ruby setlocal tabstop=2 shiftwidth=2
autocmd FileType yaml setlocal tabstop=2 shiftwidth=2
autocmd FileType tf setlocal tabstop=2 shiftwidth=2
]]--
opt.autoindent = true

-- command completion
opt.wildmenu = true
opt.wildmode = 'list:longest'

-- add '-' and '_' as part of a keyword
opt.iskeyword:append("-", "_")
46 changes: 46 additions & 0 deletions nvim/lua/plugins-setup.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- 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 manages itself
use("wbthomason/packer.nvim")

use("folke/tokyonight.nvim") -- preferred colorscheme
use("szw/vim-maximizer") -- maximizes and restores current window
use("tpope/vim-surround") -- add, delete, change surroundings (it's awesome)
use("inkarkat/vim-ReplaceWithRegister") -- replace with register contents using motion (gr + motion)
use("numToStr/Comment.nvim") -- commenting with gc
use("nvim-tree/nvim-tree.lua") -- file explorer
use("nvim-tree/nvim-web-devicons") -- icons
use("nvim-lualine/lualine.nvim") -- statusline

if packer_bootstrap then
require("packer").sync()
end
end)
8 changes: 8 additions & 0 deletions nvim/lua/plugins/comment.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- import comment plugin safely
local setup, comment = pcall(require, "Comment")
if not setup then
return
end

-- enable comment
comment.setup()
41 changes: 41 additions & 0 deletions nvim/lua/plugins/lualine.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- import lualine plugin safely
local status, lualine = pcall(require, "lualine")
if not status then
return
end

lualine.setup({
options = {
theme = 'tokyonight'
}
})
-- get lualine tokyonight theme
-- local lualine_tokyonight = require("lualine.themes.tokyonight")
--
-- -- new colors for theme
-- local new_colors = {
-- blue = "#65D1FF",
-- green = "#3EFFDC",
-- violet = "#FF61EF",
-- yellow = "#FFDA7B",
-- black = "#000000",
-- }
--
-- -- change nightlfy theme colors
-- lualine_tokyonight.normal.a.bg = new_colors.blue
-- lualine_tokyonight.insert.a.bg = new_colors.green
-- lualine_tokyonight.visual.a.bg = new_colors.violet
-- lualine_tokyonight.command = {
-- a = {
-- gui = "bold",
-- bg = new_colors.yellow,
-- fg = new_colors.black, -- black
-- },
-- }
--
-- -- configure lualine with modified theme
-- lualine.setup({
-- options = {
-- theme = lualine_tokyonight,
-- },
-- })
49 changes: 49 additions & 0 deletions nvim/lua/plugins/nvim-tree.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
-- 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_netrw = 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,
},
},
},
view = {
mappings = {
list = {
{ key = "v", action = "vsplit" },
{ key = "h", action = "split" },
}
}
},
-- git = {
-- ignore = false,
-- },
})

Loading