summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/talha/autocmds.lua2
-rw-r--r--lua/talha/functions.lua71
-rw-r--r--lua/talha/init.lua1
-rw-r--r--lua/talha/lazy.lua42
-rw-r--r--lua/talha/remap.lua25
-rw-r--r--lua/talha/set.lua22
6 files changed, 83 insertions, 80 deletions
diff --git a/lua/talha/autocmds.lua b/lua/talha/autocmds.lua
index 4ce8ae4..4adeb03 100644
--- a/lua/talha/autocmds.lua
+++ b/lua/talha/autocmds.lua
@@ -5,5 +5,3 @@ vim.api.nvim_create_autocmd({ "CursorHold" }, {
command = "silent! checktime",
group = autocmd_group,
})
-
-
diff --git a/lua/talha/functions.lua b/lua/talha/functions.lua
index b75185b..ff320e3 100644
--- a/lua/talha/functions.lua
+++ b/lua/talha/functions.lua
@@ -1,41 +1,8 @@
-local Path = require"plenary.path"
-
function GetCurrFileName()
local filename = vim.api.nvim_buf_get_name(0)
return filename
end
-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)
@@ -66,12 +33,6 @@ function ToggleSpellCheck()
vim.opt.spelllang = 'en_us'
end
-function SetFocusColors(mode)
- vim.o.background = "light"
- vim.opt.cursorline = false
- vim.cmd("colorscheme vscode")
-end
-
function GetHomeDir()
-- for linux/mac
local home = os.getenv("HOME")
@@ -86,17 +47,6 @@ function GetHomeDir()
return nil
end
-function GetPlatformBuildCommand()
- os_ver = vim.loop.os_uname().sysname
- local build_command = ''
- if os_ver == 'Linux' then
- build_command = [[./build.sh]]
- elseif os_ver == 'Windows' then
- build_command = [[build.bat]]
- end
- return build_command
-end
-
function SafeCListNav(navdir)
-- dir:
-- 1 is cnext (forwards)
@@ -113,3 +63,24 @@ function SafeCListNav(navdir)
return nil
end
end
+
+function MakeTags()
+ local on_exit = function(obj)
+ print('re-generated tags')
+ end
+
+ vim.system({'ctags', '-R', '.'}, {text = true}, on_exit)
+end
+
+function LoadSnippet(stype)
+ local ft = '.lua'
+ local buft = vim.bo.filetype
+ if buft == 'cpp' then
+ ft = '.c'
+ else
+ ft = '.' .. vim.bo.filetype
+ end
+ vim.cmd.read {
+ GetHomeDir() .. '/.config/nvim/snippets/' .. stype .. ft
+ }
+end
diff --git a/lua/talha/init.lua b/lua/talha/init.lua
index 477c463..94a77a5 100644
--- a/lua/talha/init.lua
+++ b/lua/talha/init.lua
@@ -3,4 +3,3 @@ require("talha.functions")
require("talha.remap")
require("talha.set")
require("talha.autocmds")
-require("talha.neovide")
diff --git a/lua/talha/lazy.lua b/lua/talha/lazy.lua
index 8ac7f43..b984c54 100644
--- a/lua/talha/lazy.lua
+++ b/lua/talha/lazy.lua
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
require("lazy").setup({
{ "nvim-lua/plenary.nvim" },
@@ -7,26 +8,28 @@ require("lazy").setup({
},
{ "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
- config = function ()
+ config = function ()
local configs = require("nvim-treesitter.configs")
configs.setup({
- ensure_installed = { "c", "vim", "vimdoc", "query", "javascript", "typescript", "python", "cpp"},
+ ensure_installed = {
+ "c", "cpp",
+ "vim", "vimdoc", "query",
+ "javascript", "typescript",
+ "python"
+ },
sync_install = false,
- highlight = {
+ highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
- indent = { enable = true },
+ indent = { enable = true },
})
end
},
"Mofiqul/vscode.nvim",
"theprimeagen/harpoon",
- "mbbill/undotree",
"tpope/vim-fugitive",
- "neomake/neomake",
- "ludovicchabant/vim-gutentags",
{
"VonHeikemen/lsp-zero.nvim",
branch = 'v2.x',
@@ -40,8 +43,31 @@ require("lazy").setup({
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'hrsh7th/cmp-buffer'}, -- Required
- {'hrsh7th/cmp-nvim-lua'},
+ {'hrsh7th/cmp-nvim-lua'},
+ {'L3MON4D3/LuaSnip'}, -- Required
+ }
+ },
+=======
+ {'hrsh7th/cmp-nvim-lua'},
{'L3MON4D3/LuaSnip'}, -- Required
}
},
+ {
+ "kristijanhusak/vim-dadbod-ui",
+ dependencies = {
+ { 'tpope/vim-dadbod', lazy = true },
+ { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true },
+ },
+ cmd = {
+ 'DBUI',
+ 'DBUIToggle',
+ 'DBUIAddConnection',
+ 'DBUIFindBuffer'
+ },
+ init = function()
+ vim.g.db_ui_use_nerd_fonts = 1
+ end,
+ }
+ --- @DISABLED
+ -- "mbbill/undotree",
})
diff --git a/lua/talha/remap.lua b/lua/talha/remap.lua
index 0569836..f2c714b 100644
--- a/lua/talha/remap.lua
+++ b/lua/talha/remap.lua
@@ -1,3 +1,14 @@
+-- easier navigation
+vim.keymap.set("n", "<C-h>", "<C-w><C-h>")
+vim.keymap.set("n", "<C-j>", "<C-w><C-j>")
+vim.keymap.set("n", "<C-k>", "<C-w><C-k>")
+vim.keymap.set("n", "<C-l>", "<C-w><C-l>")
+
+-- tab navigation
+vim.keymap.set("n", "<C-t><C-n>", vim.cmd.tabnew)
+vim.keymap.set("n", "<C-t><C-h>", vim.cmd.tabp)
+vim.keymap.set("n", "<C-t><C-l>", vim.cmd.tabn)
+
-- open project view with netrw
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
@@ -22,11 +33,6 @@ vim.keymap.set("n", "N", "Nzzzv")
vim.keymap.set("x", "<leader>p", "\"_dP")
--- Tab navigation
-vim.keymap.set("n", "<C-t>n", vim.cmd.tabn)
--- go to prev error
-vim.keymap.set("n", "<C-t>p", vim.cmd.tabp)
-
---- system clipboard
-- copying
vim.keymap.set("n", "<leader>y", [["+y]])
@@ -51,9 +57,8 @@ vim.keymap.set("n", "<A-n>", function() SafeCListNav(1) end)
-- go to prev error
vim.keymap.set("n", "<A-p>", function() SafeCListNav(-1) end)
-- open error list when there are errors
-vim.keymap.set("n", "<A-e>", vim.cmd.cw)
+vim.keymap.set("n", "<A-w>", vim.cmd.cw)
+
+---- snippets
+vim.keymap.set("n", "<A-s>", [[:lua LoadSnippet('')<Left><Left>]])
--- building
-vim.keymap.set("n", "<F5>", function()
- vim.cmd.Neomake{bang=true};
-end)
diff --git a/lua/talha/set.lua b/lua/talha/set.lua
index c2c578d..91129ad 100644
--- a/lua/talha/set.lua
+++ b/lua/talha/set.lua
@@ -3,13 +3,12 @@ local op = vim.opt
op.nu = true
op.relativenumber = true
-op.tabstop = 2
op.softtabstop = 2
op.shiftwidth = 2
-op.expandtab = true
+op.expandtab = false
-op.smartindent = true
-op.wrap = false
+op.cindent = true
+op.wrap = true
op.swapfile = false
op.backup = false
@@ -28,11 +27,16 @@ op.autoread = true
op.updatetime = 50
-op.colorcolumn = '120'
+op.colorcolumn = '80'
+if vim.fn.executable('rg') > 0 then
+ op.grepprg = 'rg --vimgrep'
+end
+
+-- netrw settings
-- required to allow mm (mark-move) command to move file
vim.g.netrw_keepdir = 1
-
--- building c/cpp files
-vim.opt.makeprg = GetPlatformBuildCommand()
-
+vim.g.netrw_banner = 0
+--vim.g.netrw_browse_split = 4
+vim.g.netrw_altv = 1
+--vim.g.netrw_liststyle = 3