diff options
author | talha <talha@talhaamir.xyz> | 2024-04-23 00:43:02 +0500 |
---|---|---|
committer | talha <talha@talhaamir.xyz> | 2024-04-23 00:43:02 +0500 |
commit | f4431f6d75baa71aa23318ea50bea3848f946ab1 (patch) | |
tree | b68fdc45b210d7c8adf2db39a2e7d499ccc1ba6f /lua/talha | |
parent | 721ef14cf3906992d8615456493de439ada8e1b8 (diff) |
Migrated to lazy.nvim, added neomake, a few remaps
Diffstat (limited to 'lua/talha')
-rw-r--r-- | lua/talha/functions.lua | 27 | ||||
-rw-r--r-- | lua/talha/init.lua | 3 | ||||
-rw-r--r-- | lua/talha/lazy.lua | 45 | ||||
-rw-r--r-- | lua/talha/packer.lua | 45 | ||||
-rw-r--r-- | lua/talha/remap.lua | 23 | ||||
-rw-r--r-- | lua/talha/set.lua | 4 |
6 files changed, 94 insertions, 53 deletions
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() + |