custom-hypr - add: nvim config
This commit is contained in:
44
.config/nvim/lua/core/autocmds.lua
Normal file
44
.config/nvim/lua/core/autocmds.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
-- Some commands that I want to execute in specific timing
|
||||
vim.api.nvim_create_augroup("disable_comment_newline", { clear = true })
|
||||
vim.api.nvim_create_augroup("auto_wrap", { clear = true })
|
||||
vim.api.nvim_create_augroup("disable_suspend_with_c_z", { clear = true })
|
||||
vim.api.nvim_create_augroup("clear_last_search", { clear = true })
|
||||
|
||||
-- NOTE: CursorLineNr setting
|
||||
vim.api.nvim_set_hl(0, "CursorLineNr", { fg = "#FFD700", bg = "none", bold = true })
|
||||
-- NOTE: visual line colors
|
||||
vim.api.nvim_set_hl(0, "Visual", { fg = "#000000", bg = "#FFFFFF", bold = true })
|
||||
|
||||
-- NOTE: Set colors for hightlights for similar words
|
||||
-- vim.api.nvim_set_hl(0, "LspReferenceRead", { fg = "#FF0000" })
|
||||
-- vim.api.nvim_set_hl(0, "LspReferenceWrite", { fg = "#FF0000" })
|
||||
-- vim.api.nvim_set_hl(0, "LspReferenceText", { fg = "#FF0000" })
|
||||
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
desc = "Disable auto insert comment newline",
|
||||
group = "disable_comment_newline",
|
||||
command = "set formatoptions-=cro",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
desc = "Enable wrap and spell for text like documents",
|
||||
group = "auto_wrap",
|
||||
pattern = { "gitcommit", "markdown", "text", "plaintext" },
|
||||
callback = function()
|
||||
vim.opt_local.wrap = true
|
||||
vim.opt_local.spell = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
desc = "Remap <C-z> to nothing so that it doesn't suspend terminal",
|
||||
group = "disable_suspend_with_c_z",
|
||||
command = "nnoremap <c-z> <nop>",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWinEnter", {
|
||||
desc = "Clear last search pattern",
|
||||
group = "clear_last_search",
|
||||
pattern = "*",
|
||||
command = "let @/ = ''",
|
||||
})
|
||||
60
.config/nvim/lua/core/mappings.lua
Normal file
60
.config/nvim/lua/core/mappings.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
-- Mapping data with "desc" stored directly by vim.keymap.set().
|
||||
--
|
||||
-- Please use this mappings table to set keyboard mapping since this is the
|
||||
-- lower level configuration and more robust one. (which-key will
|
||||
-- automatically pick-up stored data by this setting.)
|
||||
|
||||
return function()
|
||||
local mappings = require("astrocore").empty_map_table()
|
||||
|
||||
-------------------------------------------
|
||||
------- Disable default mappings ----------
|
||||
-------------------------------------------
|
||||
mappings.n["<C-H>"] = false
|
||||
mappings.n["<C-L>"] = false
|
||||
mappings.n["<C-K>"] = false
|
||||
mappings.n["<C-J>"] = false
|
||||
mappings.n["<C-Left>"] = false
|
||||
mappings.n["<C-Right>"] = false
|
||||
mappings.n["<C-Up>"] = false
|
||||
mappings.n["<C-Down>"] = false
|
||||
|
||||
-------------------------------------------
|
||||
----------- Utility functions -------------
|
||||
-------------------------------------------
|
||||
mappings.n["<C-z>"] = { "u", desc = "Undo" }
|
||||
-- mappings.n["<S-k>"] = { "u", desc = "Undo" }
|
||||
mappings.n["K"] = { function() vim.lsp.buf.hover() end, desc = "Hover symbol details"}
|
||||
|
||||
mappings.i["<C-z>"] = { "<C-o>u", desc = "Undo" }
|
||||
mappings.i["<C-Del>"] = { "<C-o>dw", desc = "Delete a word backward" }
|
||||
mappings.i["<C-s>"] = { "<Cmd>w!<CR>", desc = "Save file" }
|
||||
mappings.i["jj"] = { "<Esc>", desc = "Normal mode" }
|
||||
|
||||
mappings.i["<S-Tab>"] = { "<C-d>", desc = "Unindent line" }
|
||||
mappings.v["<Tab>"] = { ">gv", desc = "Indent line" }
|
||||
mappings.v["<S-Tab>"] = { "<gv", desc = "Unindent line" }
|
||||
|
||||
-- Separate cut and delete motion
|
||||
-- for key, map in pairs {
|
||||
-- ["d"] = { '"_d', desc = "Delete" },
|
||||
-- ["X"] = { "d", desc = "Cut" },
|
||||
-- } do
|
||||
-- mappings.n[key] = map
|
||||
-- mappings.v[key] = map
|
||||
-- end
|
||||
|
||||
------ Motions related to jumping or selecting ------
|
||||
-- for key, map in pairs {
|
||||
-- ["H"] = { "^", desc = "Jump to beginning of line" },
|
||||
-- ["L"] = { "$", desc = "Jump to end of line" },
|
||||
-- ["K"] = { "5k", desc = "Move up 5 lines" },
|
||||
-- ["J"] = { "5j", desc = "Move down 5 lines" },
|
||||
-- } do
|
||||
-- mappings.n[key] = map
|
||||
-- mappings.v[key] = map
|
||||
-- end
|
||||
mappings.n["<C-a>"] = { "ggVG", desc = "Select all lines" }
|
||||
|
||||
return mappings
|
||||
end
|
||||
33
.config/nvim/lua/core/options.lua
Normal file
33
.config/nvim/lua/core/options.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
return {
|
||||
-- vim.opt.<key>
|
||||
opt = {
|
||||
number = true, -- show line number
|
||||
relativenumber = true, -- show relative line number
|
||||
spell = false, -- disable spell check
|
||||
wrap = false, -- disable auto wrap lines
|
||||
signcolumn = "yes", -- show changes of file
|
||||
foldcolumn = "1", -- show foldcolumn
|
||||
foldenable = true, -- enable fold for nvim-ufo
|
||||
foldlevel = 99, -- set high foldlevel for nvim-ufo
|
||||
foldlevelstart = 99, -- start with all code unfolded
|
||||
guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20", -- default cursor setting
|
||||
clipboard = "unnamedplus", -- enable system clipboard
|
||||
termguicolors = true, -- true color support
|
||||
mouse = "a", -- enable mouse
|
||||
mousemoveevent = true, -- enable mousemove event
|
||||
laststatus = 3, -- only show one statusline
|
||||
swapfile = false, -- don't use swapfile
|
||||
shiftwidth = 2, -- number of space inserted for indentation; when zero the 'tabstop' value will be used
|
||||
tabstop = 2, -- set the number of space in a tab to 4
|
||||
softtabstop = 2, -- can be differnt from tabstop
|
||||
showtabline = 0, -- always show tabline
|
||||
expandtab = true, -- use spaces instead of tab
|
||||
undofile = true, -- enable persistent undo
|
||||
},
|
||||
-- vim.g.<key>
|
||||
g = {
|
||||
-- configure global vim variables (vim.g)
|
||||
-- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup`
|
||||
-- This can be found in the `lua/lazy_setup.lua` file
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user