summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/talha/functions.lua25
-rw-r--r--lua/talha/init.lua2
-rw-r--r--lua/talha/lazy.lua1
-rw-r--r--lua/talha/plugins/harpoon.lua12
-rw-r--r--lua/talha/plugins/lsp.lua122
-rw-r--r--lua/talha/plugins/telescope.lua7
-rw-r--r--lua/talha/plugins/treesitter.lua6
-rw-r--r--lua/talha/remap.lua9
-rw-r--r--lua/talha/set.lua2
9 files changed, 21 insertions, 165 deletions
diff --git a/lua/talha/functions.lua b/lua/talha/functions.lua
index 2a26483..06a66d5 100644
--- a/lua/talha/functions.lua
+++ b/lua/talha/functions.lua
@@ -3,31 +3,6 @@ function GetCurrFileName()
return 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'
diff --git a/lua/talha/init.lua b/lua/talha/init.lua
index 94a77a5..7b2074b 100644
--- a/lua/talha/init.lua
+++ b/lua/talha/init.lua
@@ -3,3 +3,5 @@ require("talha.functions")
require("talha.remap")
require("talha.set")
require("talha.autocmds")
+
+vim.lsp.enable('clangd')
diff --git a/lua/talha/lazy.lua b/lua/talha/lazy.lua
index fc79bae..5eb32fe 100644
--- a/lua/talha/lazy.lua
+++ b/lua/talha/lazy.lua
@@ -16,7 +16,6 @@ end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
- "Mofiqul/vscode.nvim",
{ "bluz71/vim-moonfly-colors", name = "moonfly", lazy = false, priority = 1000 },
{ "nvim-lua/plenary.nvim" },
{ import = "talha.plugins" },
diff --git a/lua/talha/plugins/harpoon.lua b/lua/talha/plugins/harpoon.lua
index 96bbbcd..7a5501b 100644
--- a/lua/talha/plugins/harpoon.lua
+++ b/lua/talha/plugins/harpoon.lua
@@ -5,13 +5,13 @@ return {
local mark = require("harpoon.mark")
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-j><C-a>", mark.add_file)
+ vim.keymap.set("n", "<C-j><C-m>", ui.toggle_quick_menu)
- 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)
+ vim.keymap.set("n", "<C-j>1", function() ui.nav_file(1) end)
+ vim.keymap.set("n", "<C-j>2", function() ui.nav_file(2) end)
+ vim.keymap.set("n", "<C-j>3", function() ui.nav_file(3) end)
+ vim.keymap.set("n", "<C-j>4", function() ui.nav_file(4) end)
end
}
}
diff --git a/lua/talha/plugins/lsp.lua b/lua/talha/plugins/lsp.lua
deleted file mode 100644
index 2ceebde..0000000
--- a/lua/talha/plugins/lsp.lua
+++ /dev/null
@@ -1,122 +0,0 @@
-return {
- {
- "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
- {'hrsh7th/cmp-buffer'}, -- Required
- {'hrsh7th/cmp-nvim-lua'},
- {'L3MON4D3/LuaSnip'}, -- Required
- },
- config = function()
-
-local lsp = require('lsp-zero').preset({})
--- @notes on Lsp and Cmp configs here:
---[[
-
-# LSP
-1. Renamed the keymaps to what I use
-2. Added a custom handler for formatting files.
- It checks the explicitly defined language servers passed and if they allow formatting, only then will it attempt
- to format the buffer
-
-# Complete
-Completion is done by nvim-cmp. The setup for that does a few things.
-1. Defines the sources to use for autocompletion:
- a. LSP server
- b. nvim-lua: only active in lua file I think
- c. buffer: uses the current file for auto-completion (similar to default nvim behavior)
-2. By default it pops up a list for auto-completion, we have that disabled.
-3. When having auto-complete disabled, it takes extra steps to trigger autocomplete, due
- to this we need to have it preselect the first item upon triggering autocomplete.
-4. We define some custom mappings
---]]
-
- local function allow_format(servers)
- return function(client) return vim.tbl_contains(servers, client.name) end
- end
-
-
- lsp.on_attach(function(client, bufnr)
- -- see :help lsp-zero-keybindings
- -- to learn the available actions
- local opts = {buffer = bufnr, remap = false}
- vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
- vim.keymap.set("n", "gD", function() vim.lsp.buf.declaration() end, opts)
- vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
- vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
- vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
- vim.keymap.set("n", "[d", function() vim.diagnostic.goto_prev() end, opts)
- vim.keymap.set("n", "]d", function() vim.diagnostic.goto_next() end, opts)
- vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
- vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
- vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
- vim.keymap.set("i", "<C-s>", function() vim.lsp.buf.signature_help() end, opts)
- vim.keymap.set("n", "<leader>vlf", function()
- vim.lsp.buf.format({
- async = false,
- timeout_ms = 10000,
- filter = allow_format({'rust_analyzer', 'tsserver', 'gopls', 'clangd', 'html-lsp'}),
- })
- end, opts)
- end)
-
- require('lspconfig').lua_ls.setup({
- settings = {
- Lua = {
- diagnostics = {
- globals = { 'vim' }
- }
- }
- }
- })
-
- lsp.setup()
-
- -- @todo: Look at luasnip and why I would require it
-
-
- local cmp = require('cmp')
- local cmp_action = require('lsp-zero').cmp_action()
-
-
- cmp.setup({
- sources = {
- { name = 'nvim_lsp' },
- { name = 'nvim_lua' },
- { name = 'buffer' },
- },
- preselect = 'item',
- completion = {
- autocomplete = false,
- completeopt = 'menu,menuone,noinsert'
- },
- mapping = cmp.mapping.preset.insert({
- -- Ctrl+Space to trigger completion menu
- ['<C-Space>'] = cmp.mapping.complete(),
-
- -- Navigate between snippet placeholder
- -- @note: don't know what this is
- ['<C-f>'] = cmp_action.luasnip_jump_forward(),
- ['<C-b>'] = cmp_action.luasnip_jump_backward(),
-
- -- Scroll up and down in the completion documentation
- ['<C-u>'] = cmp.mapping.scroll_docs(-4),
- ['<C-d>'] = cmp.mapping.scroll_docs(4),
- }),
- snippet = {
- expand = function(args)
- require('luasnip').lsp_expand(args.body)
- end,
- },
- })
- end
- },
-}
diff --git a/lua/talha/plugins/telescope.lua b/lua/talha/plugins/telescope.lua
index c380c79..8b3a54b 100644
--- a/lua/talha/plugins/telescope.lua
+++ b/lua/talha/plugins/telescope.lua
@@ -7,7 +7,12 @@ return {
vim.keymap.set('n', '<leader>pf', builtin.find_files)
vim.keymap.set('n', '<C-p>', builtin.git_files)
vim.keymap.set('n', '<leader>ps', builtin.live_grep)
- vim.keymap.set('n', '<leader>gw', builtin.grep_string)
+ vim.keymap.set('n', '<leader>pw', builtin.grep_string)
+ vim.keymap.set('n', '<leader>ch', builtin.command_history)
+ vim.keymap.set('n', '<leader>sh', builtin.search_history)
+ vim.keymap.set('n', '<leader>pb', builtin.buffers)
+ vim.keymap.set('n', '<leader>ph', builtin.help_tags)
+ vim.keymap.set('n', '<leader>mp', builtin.man_pages)
end
}
}
diff --git a/lua/talha/plugins/treesitter.lua b/lua/talha/plugins/treesitter.lua
index 3f1efc7..53d3ca0 100644
--- a/lua/talha/plugins/treesitter.lua
+++ b/lua/talha/plugins/treesitter.lua
@@ -1,6 +1,8 @@
return {
{
- "nvim-treesitter/nvim-treesitter",build = ":TSUpdate",
+ "nvim-treesitter/nvim-treesitter",
+ lazy = false,
+ build = ":TSUpdate",
config = function ()
local configs = require("nvim-treesitter.configs")
@@ -14,7 +16,7 @@ return {
enable = true,
additional_vim_regex_highlighting = false,
},
- indent = { enable = false },
+ indent = { enable = true },
})
end
}
diff --git a/lua/talha/remap.lua b/lua/talha/remap.lua
index 9e59dc9..ee80890 100644
--- a/lua/talha/remap.lua
+++ b/lua/talha/remap.lua
@@ -14,12 +14,6 @@ vim.keymap.set("n", "<leader>hs", vim.cmd.split)
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")
-
-vim.keymap.set("x", "<leader>p", "\"_dP")
-
---- system clipboard
-- copying
vim.keymap.set("n", "<leader>y", [["+y]])
@@ -27,6 +21,7 @@ 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("x", "<leader>p", "\"_dP")
vim.keymap.set("n", "<leader>p", [["+p]])
vim.keymap.set("n", "<leader>P", [["+P]])
vim.keymap.set("v", "<leader>p", [["+p]])
@@ -44,4 +39,4 @@ 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-w>", vim.cmd.cw)
+vim.keymap.set("n", "<A-l>", vim.cmd.cw)
diff --git a/lua/talha/set.lua b/lua/talha/set.lua
index 508a198..a7888b3 100644
--- a/lua/talha/set.lua
+++ b/lua/talha/set.lua
@@ -30,6 +30,7 @@ op.updatetime = 50
op.cursorline = false
op.colorcolumn = '80'
+
vim.cmd[[ colorscheme moonfly ]]
if vim.fn.executable('rg') > 0 then
@@ -37,7 +38,6 @@ if vim.fn.executable('rg') > 0 then
end
-- netrw settings
--- required to allow mm (mark-move) command to move file
vim.g.netrw_keepdir = 1
vim.g.netrw_banner = 0
vim.g.netrw_altv = 1