summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--after/plugin/harpoon.lua8
-rw-r--r--after/plugin/lsp.lua6
-rw-r--r--after/plugin/telescope.lua4
-rw-r--r--after/plugin/treesitter.lua21
-rw-r--r--init.lua18
-rw-r--r--lazy-lock.json19
-rw-r--r--lua/talha/functions.lua27
-rw-r--r--lua/talha/init.lua3
-rw-r--r--lua/talha/lazy.lua45
-rw-r--r--lua/talha/packer.lua45
-rw-r--r--lua/talha/remap.lua23
-rw-r--r--lua/talha/set.lua4
12 files changed, 138 insertions, 85 deletions
diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua
index 7d2a7a6..a24b20d 100644
--- a/after/plugin/harpoon.lua
+++ b/after/plugin/harpoon.lua
@@ -4,7 +4,7 @@ local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
-vim.keymap.set("n", "<C-f>y", function() ui.nav_file(1) end)
-vim.keymap.set("n", "<C-f>u", function() ui.nav_file(2) end)
-vim.keymap.set("n", "<C-f>i", function() ui.nav_file(3) end)
-vim.keymap.set("n", "<C-f>o", function() ui.nav_file(4) end)
+vim.keymap.set("n", "<C-f>1", function() ui.nav_file(1) end)
+vim.keymap.set("n", "<C-f>2", function() ui.nav_file(2) end)
+vim.keymap.set("n", "<C-f>3", function() ui.nav_file(3) end)
+vim.keymap.set("n", "<C-f>4", function() ui.nav_file(4) end)
diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua
index f8dae3c..7d8e3ab 100644
--- a/after/plugin/lsp.lua
+++ b/after/plugin/lsp.lua
@@ -1,10 +1,5 @@
local lsp = require('lsp-zero').preset({})
-local function allow_format(servers)
- return function(client) return vim.tbl_contains(servers, client.name) end
-end
-
-
-- TODO: add bindings to work when no lsp available, to allow normal functionality
lsp.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings
@@ -23,3 +18,4 @@ lsp.on_attach(function(client, bufnr)
end)
lsp.setup()
+
diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua
index 4806008..b007673 100644
--- a/after/plugin/telescope.lua
+++ b/after/plugin/telescope.lua
@@ -1,6 +1,6 @@
local builtin = require('telescope.builtin')
-vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
+vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
-vim.keymap.set('n', '<leader>ps', function()
+vim.keymap.set('n', '<leader>fs', function()
builtin.grep_string({ search = vim.fn.input("Grep > ") });
end)
diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua
deleted file mode 100644
index d0ee3dc..0000000
--- a/after/plugin/treesitter.lua
+++ /dev/null
@@ -1,21 +0,0 @@
-require'nvim-treesitter.configs'.setup {
- -- A list of parser names, or "all" (the five listed parsers should always be installed)
- ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "javascript", "typescript", "python", "cpp"},
-
- -- Install parsers synchronously (only applied to `ensure_installed`)
- sync_install = false,
-
- -- Automatically install missing parsers when entering buffer
- -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
- auto_install = true,
-
- highlight = {
- enable = true,
-
- -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
- -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
- -- Using this option may slow down your editor, and you may see some duplicate highlights.
- -- Instead of true it can also be a list of languages
- additional_vim_regex_highlighting = false,
- },
-}
diff --git a/init.lua b/init.lua
index 1105fe8..4a33ff0 100644
--- a/init.lua
+++ b/init.lua
@@ -1 +1,19 @@
+-- setup lazy
+local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
+if not (vim.uv or vim.loop).fs_stat(lazypath) then
+ vim.fn.system({
+ "git",
+ "clone",
+ "--filter=blob:none",
+ "https://github.com/folke/lazy.nvim.git",
+ "--branch=stable", -- latest stable release
+ lazypath,
+ })
+end
+vim.opt.rtp:prepend(lazypath)
+
+-- setup leader key
+vim.g.mapleader = " "
+
require("talha")
+
diff --git a/lazy-lock.json b/lazy-lock.json
new file mode 100644
index 0000000..270621b
--- /dev/null
+++ b/lazy-lock.json
@@ -0,0 +1,19 @@
+{
+ "LuaSnip": { "branch": "master", "commit": "72eea98b1900013e0cb214f29b898c8d91564930" },
+ "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
+ "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" },
+ "lazy.nvim": { "branch": "main", "commit": "3f13f080434ac942b150679223d54f5ca91e0d52" },
+ "lsp-zero.nvim": { "branch": "v2.x", "commit": "9a686513eaaa13d737d0fec8956a18268ead8b29" },
+ "mason-lspconfig.nvim": { "branch": "main", "commit": "f3658bfc667df6a0340194a015ac2f31c1e675e0" },
+ "mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" },
+ "neomake": { "branch": "master", "commit": "584f882b9f991245374e7e7d7d1f78bae90b7a35" },
+ "nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" },
+ "nvim-lspconfig": { "branch": "master", "commit": "ed8b8a15acc441aec669f97d75f2c1f2ac8c8aa5" },
+ "nvim-treesitter": { "branch": "master", "commit": "c1d1b4084ef5239e2671f64d35962d184251aea4" },
+ "plenary.nvim": { "branch": "master", "commit": "5129a3693c482fcbc5ab99a7706ffc4360b995a0" },
+ "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" },
+ "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" },
+ "vim-fugitive": { "branch": "master", "commit": "dac8e5c2d85926df92672bf2afb4fc48656d96c7" },
+ "vim-gutentags": { "branch": "master", "commit": "aa47c5e29c37c52176c44e61c780032dfacef3dd" },
+ "vscode.nvim": { "branch": "main", "commit": "d47aab1fbe423bf14275745684205dca08366277" }
+} \ No newline at end of file
diff --git a/lua/talha/functions.lua b/lua/talha/functions.lua
index e27e1a2..fdad26c 100644
--- a/lua/talha/functions.lua
+++ b/lua/talha/functions.lua
@@ -87,3 +87,30 @@ 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)
+ -- -1 is cprev (backwards)
+ local dircmd = ''
+ if navdir == 1 then
+ dircmd = 'cnext'
+ elseif navdir == -1 then
+ dircmd = 'cprev'
+ end
+ local status, result = pcall(vim.cmd, dircmd)
+
+ if status == false then
+ return nil
+ end
+end
diff --git a/lua/talha/init.lua b/lua/talha/init.lua
index 43f9548..477c463 100644
--- a/lua/talha/init.lua
+++ b/lua/talha/init.lua
@@ -1,7 +1,6 @@
+require("talha.lazy")
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
new file mode 100644
index 0000000..089f254
--- /dev/null
+++ b/lua/talha/lazy.lua
@@ -0,0 +1,45 @@
+
+require("lazy").setup({
+ { "nvim-lua/plenary.nvim" },
+ {
+ "nvim-telescope/telescope.nvim", version = "0.1.2",
+ dependencies = { "nvim-lua/plenary.nvim" }
+ },
+ { "nvim-treesitter/nvim-treesitter",
+ build = ":TSUpdate",
+ config = function ()
+ local configs = require("nvim-treesitter.configs")
+
+ configs.setup({
+ ensure_installed = { "c", "vim", "vimdoc", "query", "javascript", "typescript", "python", "cpp"},
+ sync_install = false,
+ highlight = {
+ enable = true,
+ additional_vim_regex_highlighting = false,
+ },
+ 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',
+ dependencies = {
+ -- 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
+ }
+ },
+})
diff --git a/lua/talha/packer.lua b/lua/talha/packer.lua
deleted file mode 100644
index e226f93..0000000
--- a/lua/talha/packer.lua
+++ /dev/null
@@ -1,45 +0,0 @@
-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 {'Mofiqul/vscode.nvim'}
-
- use { "theprimeagen/harpoon" }
-
- use('mbbill/undotree')
-
- use('tpope/vim-fugitive')
-
- use({
- 'ludovicchabant/vim-gutentags',
- ft={'h', 'hpp', 'c', 'cpp'}
- })
-
- 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/talha/remap.lua b/lua/talha/remap.lua
index 882d651..cfd6624 100644
--- a/lua/talha/remap.lua
+++ b/lua/talha/remap.lua
@@ -1,5 +1,3 @@
-vim.g.mapleader = " "
-
-- open project view with netrw
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
@@ -24,10 +22,16 @@ vim.keymap.set("n", "N", "Nzzzv")
vim.keymap.set("x", "<leader>p", "\"_dP")
--- copying to system clipboard
+---- system clipboard
+-- copying
vim.keymap.set("n", "<leader>y", [["+y]])
vim.keymap.set("v", "<leader>y", [["+y]])
vim.keymap.set("n", "<leader>Y", [["+Y]])
+-- pasting
+-- @note: for posting in insert mode use: <C-r>+
+vim.keymap.set("n", "<leader>p", [["+p]])
+vim.keymap.set("n", "<leader>P", [["+P]])
+vim.keymap.set("v", "<leader>p", [["+p]])
-- deleting without polluting vim clipboard
vim.keymap.set({"n", "x"}, "x", [["_x]])
@@ -36,6 +40,13 @@ vim.keymap.set({"n", "x"}, "X", [["_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>]])
--- remapping quickfix list navigation
-vim.keymap.set("n", "<C-f>l", vim.cmd.cnext)
-vim.keymap.set("n", "<C-f>h", vim.cmd.cprev)
+---- remapping quickfix list navigation
+-- go to next error
+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)
+
+-- building
+-- vim.keymap.set("n", "<F5>", vim.cmd.Neomake{bang=true})
diff --git a/lua/talha/set.lua b/lua/talha/set.lua
index 68b6ee6..c2c578d 100644
--- a/lua/talha/set.lua
+++ b/lua/talha/set.lua
@@ -32,3 +32,7 @@ op.colorcolumn = '120'
-- required to allow mm (mark-move) command to move file
vim.g.netrw_keepdir = 1
+
+-- building c/cpp files
+vim.opt.makeprg = GetPlatformBuildCommand()
+