summaryrefslogtreecommitdiff
path: root/lua/linux
diff options
context:
space:
mode:
Diffstat (limited to 'lua/linux')
-rw-r--r--lua/linux/functions.lua62
-rw-r--r--lua/linux/init.lua4
-rw-r--r--lua/linux/packer.lua41
-rw-r--r--lua/linux/remap.lua35
-rw-r--r--lua/linux/set.lua36
5 files changed, 178 insertions, 0 deletions
diff --git a/lua/linux/functions.lua b/lua/linux/functions.lua
new file mode 100644
index 0000000..946bfd8
--- /dev/null
+++ b/lua/linux/functions.lua
@@ -0,0 +1,62 @@
+local Path = require"plenary.path"
+
+function CreateDailyNote()
+ local file_path = vim.api.nvim_buf_get_name(0)
+ local dir_path = file_path
+ local path_obj = Path:new(file_path)
+
+ if path_obj:is_file() == true then
+ path_obj = path_obj:parent() -- get the parent directory
+ dir_path = path_obj:_fs_filename()
+ end
+
+ local today_date_fmt = os.date('%Y-%m-%d')
+ local daily_note_file_name = today_date_fmt .. '.md'
+ local daily_note_file_obj = path_obj:joinpath(daily_note_file_name)
+
+ local template_file_name = '.daily-notes-template.md'
+ local template_file_obj = path_obj:joinpath(template_file_name)
+
+ local status = template_file_obj:copy({destination=daily_note_file_obj})
+
+ -- check if operation was a success
+ if status[daily_note_file_obj] == false then
+ print('Error! failed to create daily note')
+ print([[Possible Causes:
+ 1. No `.daily-notes-template.md` found
+ 2. Something went wrong with copy, in which case check nvim config]])
+ return
+ end
+
+ vim.cmd('e ' .. daily_note_file_obj:_fs_filename())
+end
+
+local function _ReloadConfigsInPath(path_selector)
+ local config_paths = vim.fn.glob(path_selector, true, true)
+
+ for _, filepath in ipairs(config_paths) do
+ dofile(filepath)
+ end
+end
+
+function ReloadLuaConfig()
+ for name,_ in pairs(package.loaded) do
+ if name:match('^linux') then
+ package.loaded[name] = nil
+ end
+ end
+
+ -- Reload init/ directory
+ local lua_path_selector = vim.fn.stdpath('config') .. '/lua/**/*.lua'
+ _ReloadConfigsInPath(lua_path_selector)
+
+ -- local after_path_selector = vim.fn.stdpath('config') .. '/after/**/*.lua'
+ _ReloadConfigsInPath(after_path_selector)
+
+ print('Nvim configurations reloaded')
+end
+
+function ToggleSpellCheck()
+ vim.opt.spell = not(vim.opt.spell:get())
+ vim.opt.spelllang = 'en_us'
+end
diff --git a/lua/linux/init.lua b/lua/linux/init.lua
new file mode 100644
index 0000000..0fbdc54
--- /dev/null
+++ b/lua/linux/init.lua
@@ -0,0 +1,4 @@
+require("linux.remap")
+require("linux.set")
+require("linux.functions")
+
diff --git a/lua/linux/packer.lua b/lua/linux/packer.lua
new file mode 100644
index 0000000..704531a
--- /dev/null
+++ b/lua/linux/packer.lua
@@ -0,0 +1,41 @@
+-- TODO: add formatter
+vim.cmd [[packadd packer.nvim]]
+
+return require('packer').startup(function(use)
+ -- Packer can manage itself
+ use 'wbthomason/packer.nvim'
+
+ use {
+ 'nvim-telescope/telescope.nvim', tag = '0.1.2',
+ -- or , branch = '0.1.x',
+ requires = { {'nvim-lua/plenary.nvim'} }
+ }
+
+
+ use({ 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' })
+
+ -- colorschemes
+ use { "ellisonleao/gruvbox.nvim" }
+ use { "huyvohcmc/atlas.vim" }
+ use { "yorickpeterse/vim-paper" }
+
+ use('mbbill/undotree')
+
+ use('tpope/vim-fugitive')
+
+ use {
+ 'VonHeikemen/lsp-zero.nvim',
+ branch = 'v2.x',
+ requires = {
+ -- LSP Support
+ {'neovim/nvim-lspconfig'}, -- Required
+ {'williamboman/mason.nvim'}, -- Optional
+ {'williamboman/mason-lspconfig.nvim'}, -- Optional
+
+ -- Autocompletion
+ {'hrsh7th/nvim-cmp'}, -- Required
+ {'hrsh7th/cmp-nvim-lsp'}, -- Required
+ {'L3MON4D3/LuaSnip'}, -- Required
+ }
+ }
+end)
diff --git a/lua/linux/remap.lua b/lua/linux/remap.lua
new file mode 100644
index 0000000..dfc7aca
--- /dev/null
+++ b/lua/linux/remap.lua
@@ -0,0 +1,35 @@
+vim.g.mapleader = " "
+
+-- open project view with netrw
+vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
+
+-- file splitting
+vim.keymap.set("n", "<leader>vs", vim.cmd.vsplit)
+vim.keymap.set("n", "<leader>hs", vim.cmd.split)
+
+-- moving selected lines across lines
+vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
+vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
+
+-- not moving cursor when bringing files up
+vim.keymap.set("n", "J", "mzJ`z")
+
+-- keep cursor in screen center when moving up and down
+vim.keymap.set("n", "<C-d>", "<C-d>zz")
+vim.keymap.set("n", "<C-u>", "<C-u>zz")
+
+-- keep cursor in screen center when traversing in find
+vim.keymap.set("n", "n", "nzzzv")
+vim.keymap.set("n", "N", "Nzzzv")
+
+-- copying to system clipboard
+vim.keymap.set("n", "<leader>y", [["+y]])
+vim.keymap.set("v", "<leader>y", [["+y]])
+vim.keymap.set("n", "<leader>Y", [["+Y]])
+
+-- deleting without polluting vim clipboard
+vim.keymap.set("n", "<leader>d", [["_d]])
+vim.keymap.set("v", "<leader>d", [["_d]])
+
+-- global substitute the word cursor is on in current file
+vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
diff --git a/lua/linux/set.lua b/lua/linux/set.lua
new file mode 100644
index 0000000..0366b03
--- /dev/null
+++ b/lua/linux/set.lua
@@ -0,0 +1,36 @@
+local op = vim.opt
+
+op.nu = true
+op.relativenumber = true
+
+op.tabstop = 2
+op.softtabstop = 2
+op.shiftwidth = 2
+op.expandtab = true
+
+op.smartindent = true
+op.wrap = false
+
+op.swapfile = false
+op.backup = false
+op.undodir = os.getenv("HOME") .. "/.vim/undodir"
+op.undofile = true
+
+op.hlsearch = false
+op.incsearch = true
+
+op.termguicolors = true
+op.cursorline = true
+
+op.scrolloff = 8
+
+-- autoreload a file after inactivity
+op.autoread = true
+vim.api.nvim_command([[au CursorHold * checktime]])
+
+op.updatetime = 50
+
+op.colorcolumn = '120'
+
+-- required to allow mm (mark-move) command to move file
+vim.g.netrw_keepdir = 0