summaryrefslogtreecommitdiff
path: root/dot_config/nvim/lua/ibrahim
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/nvim/lua/ibrahim')
-rw-r--r--dot_config/nvim/lua/ibrahim/icons.lua62
-rw-r--r--dot_config/nvim/lua/ibrahim/keys.lua124
-rw-r--r--dot_config/nvim/lua/ibrahim/set.lua64
3 files changed, 250 insertions, 0 deletions
diff --git a/dot_config/nvim/lua/ibrahim/icons.lua b/dot_config/nvim/lua/ibrahim/icons.lua
new file mode 100644
index 0000000..d6573ab
--- /dev/null
+++ b/dot_config/nvim/lua/ibrahim/icons.lua
@@ -0,0 +1,62 @@
+return {
+ diagnostics = {
+ -- Error = " ",
+ -- Warn = " ",
+ -- Hint = " ",
+ -- Info = " ",
+ Error = " ",
+ Warn = " ",
+ -- Hint = " ",
+ Hint = "󰌵 ",
+ Info = " ",
+ },
+ git = {
+ -- Change type
+ added = " ",
+ -- added = "✚"
+ modified = " ",
+ -- modified = ""
+ removed = " ",
+ deleted = "󱂑",
+ renamed = "󰑕",
+ -- Status type
+ untracked = "",
+ ignored = "",
+ unstaged = "",
+ staged = "",
+ conflict = "",
+ },
+ gitsigns = {
+ -- Signs that will appear in the statusline column
+ added = "✚",
+ modified = "",
+ deleted = "",
+ },
+ lsp = {
+ Text = "",
+ Method = "",
+ Function = "󰡱",
+ Constructor = "",
+ Field = "",
+ Variable = "󰫧",
+ Class = "",
+ Interface = "",
+ Module = "",
+ Property = "",
+ Unit = "",
+ Value = "",
+ Enum = "",
+ Keyword = "",
+ Snippet = "",
+ Color = "",
+ File = "",
+ Reference = "",
+ Folder = "",
+ EnumMember = "",
+ Constant = "",
+ Struct = "",
+ Event = "",
+ Operator = "",
+ TypeParameter = "",
+ },
+}
diff --git a/dot_config/nvim/lua/ibrahim/keys.lua b/dot_config/nvim/lua/ibrahim/keys.lua
new file mode 100644
index 0000000..fa44e69
--- /dev/null
+++ b/dot_config/nvim/lua/ibrahim/keys.lua
@@ -0,0 +1,124 @@
+-- Set leader key as Space
+vim.g.mapleader = " "
+
+local function map(mode, left, right, opts)
+ local default_opts = {
+ noremap = true,
+ silent = true,
+ }
+ opts = opts or {}
+ -- "keep" mode preserves the values from the leftmost table,
+ -- so prioritize any options provided over the defaults
+ local full_opts = vim.tbl_extend("keep", opts, default_opts)
+ vim.keymap.set(mode, left, right, full_opts)
+end
+
+-- Clear any highlighted searches when pressing Esc
+-- This lets me leave hlsearch on by default while having an easy way to clear
+-- it again.
+map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
+
+-- Move lines while in visual mode with J and K
+map("v", "J", ":m '>+1<CR>gv=gv")
+map("v", "K", ":m '<-2<CR>gv=gv")
+
+-- Keep cursor in the same place when using J to join lines
+map("n", "J", "mzJ`z")
+
+-- Center the screen when jumping around with C-d and C-u
+map("n", "<C-d>", "<C-d>zz")
+map("n", "<C-u>", "<C-u>zz")
+
+-- Center the screen when jumping to next / previous search terms
+map("n", "n", "nzzzv")
+map("n", "N", "Nzzzv")
+
+-- Quick maps to paste/delete without overwriting the current buffer
+map("x", "<leader>p", '"_dP')
+map({ "n", "v" }, "<leader>d", '"_dP')
+
+-- Easier split navigation
+map("n", "<C-h>", "<C-w>h")
+map("n", "<C-j>", "<C-w>j")
+map("n", "<C-k>", "<C-w>k")
+map("n", "<C-l>", "<C-w>l")
+
+-- System clipboard
+map({ "n", "v" }, "<leader>cd", '"+d', { desc = "Clipboard delete" })
+map({ "n", "v" }, "<leader>cp", '"+p', { desc = "Clipboard paste" })
+map({ "n", "v" }, "<leader>cy", '"+y', { desc = "Clipboard yank" })
+
+-- Map g- to netrw (temporary placeholder for oil)
+-- map("n", "g-", vim.cmd.Ex, { desc = "Open netrw" })
+
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("IbrahimLspConfig", {}),
+ callback = function(evt)
+ local function lsp_map(mode, lhs, rhs, desc)
+ local opts = { buffer = evt.buf, desc = "LSP: " .. (desc or "") }
+ map(mode, lhs, rhs, opts)
+ end
+
+ local has_telescope, _ = pcall(require, "telescope")
+ local function lsp_telescope_map(mode, lhs, with_telescope_rhs, no_telescope_rhs, desc)
+ if has_telescope then
+ desc = desc .. " (Telescope)"
+ lsp_map(mode, lhs, with_telescope_rhs, desc)
+ else
+ lsp_map(mode, lhs, no_telescope_rhs, desc)
+ end
+ end
+ local function tele_builtin(name, opts)
+ return function()
+ require("telescope.builtin")[name](opts)
+ end
+ end
+
+ -- Navigation
+ lsp_map("n", "gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
+ lsp_map("n", "gt", vim.lsp.buf.type_definition, "[G]oto [t]ype Definition")
+ lsp_map("n", "gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
+ lsp_map("n", "gr", vim.lsp.buf.references, "[G]oto [R]eferences")
+ lsp_map("n", "gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation")
+
+ lsp_telescope_map("n", "gr", tele_builtin("lsp_references"), vim.lsp.buf.references, "Go to references")
+ lsp_telescope_map(
+ "n",
+ "<leader>sn",
+ tele_builtin("lsp_document_symbols"),
+ vim.lsp.buf.document_symbol,
+ "Search document symbols"
+ )
+ lsp_telescope_map(
+ "n",
+ "<leader>sN",
+ tele_builtin("lsp_dynamic_workspace_symbols"),
+ vim.lsp.buf.workspace_symbol,
+ "Search workspace symbols"
+ )
+
+ -- Code changes
+ lsp_map("n", "<leader>cr", vim.lsp.buf.rename, "Rename")
+ lsp_map("n", "<leader>ca", vim.lsp.buf.code_action, "Code actions")
+
+ -- Diagnostics
+ lsp_map("n", "<leader>ds", vim.diagnostic.open_float, "[s]how [d]iagnostic window")
+ lsp_map("n", "<leader>dn", function()
+ vim.diagnostic.goto_next({ float = true })
+ end, "Go to [n]ext [d]iagnostic")
+ lsp_map("n", "<leader>dp", function()
+ vim.diagnostic.goto_prev({ float = true })
+ end, "Go to [p]revious [d]iagnostic")
+
+ -- See `:help K` for why this keymap
+ lsp_map("n", "K", vim.lsp.buf.hover, "Hover Documentation")
+ lsp_map("n", "<C-S-k>", vim.lsp.buf.signature_help, "Signature Documentation")
+
+ -- Workspace
+ lsp_map("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder")
+ lsp_map("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
+ lsp_map("n", "<leader>wl", function()
+ print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
+ end, "[W]orkspace [L]ist Folders")
+ end,
+})
diff --git a/dot_config/nvim/lua/ibrahim/set.lua b/dot_config/nvim/lua/ibrahim/set.lua
new file mode 100644
index 0000000..280033f
--- /dev/null
+++ b/dot_config/nvim/lua/ibrahim/set.lua
@@ -0,0 +1,64 @@
+local opt = vim.opt
+
+-- Begin searching as I type a search string instead of waiting for me to press Enter
+opt.incsearch = true
+
+-- Make line numbers default
+opt.number = true
+opt.relativenumber = true
+
+-- Highlight only the line number for the current line.
+-- Disable the second line here to highlight the entire line where the
+-- cursor is.
+opt.cursorline = true
+opt.cursorlineopt = "number"
+
+-- Try to keep this many lines visible above and below the cursor.
+-- This makes the window scroll sooner if mashing j / k.
+opt.scrolloff = 8
+
+-- Don't fold absolutely everything when opening a new file
+opt.foldlevelstart = 1
+
+-- Enable mouse mode
+opt.mouse = "a"
+
+-- Tab settings
+opt.tabstop = 4
+opt.softtabstop = 4
+opt.shiftwidth = 0
+opt.expandtab = true
+
+-- Automatically set the same indent level on a new line
+opt.autoindent = true
+
+-- Increase or decrease indent based on braces or language keywords
+opt.smartindent = true
+
+-- Enable break indent
+opt.breakindent = true
+
+-- Don't make local backup files. Instead, write undo history to disk.
+-- This works especially well with the undotree plugin.
+opt.swapfile = false
+opt.backup = false
+opt.undodir = vim.fn.expand("~/.vim/undodir")
+opt.undofile = true
+
+-- Case insensitive searching UNLESS /C or capital in search
+opt.ignorecase = true
+opt.smartcase = true
+
+-- Decrease update time
+opt.updatetime = 250
+
+-- Enable signcolumn (used for diagnostics and gitsigns)
+opt.signcolumn = "yes"
+
+-- Colored columns at 72 and 88 are for line lengths, and are based on
+-- Python conventions. Docstrings in Python should terminate at 72
+-- characters, and 88 is the max line length for the Black formatter.
+opt.colorcolumn = { 72, 88 }
+
+-- Set completeopt to have a better completion experience
+opt.completeopt = "menuone,noselect"