initial commit
This commit is contained in:
4
lua/config/init.lua
Normal file
4
lua/config/init.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
require("config.vars")
|
||||
require("config.keybinds")
|
||||
|
||||
require("config.lazy")
|
||||
75
lua/config/keybinds.lua
Normal file
75
lua/config/keybinds.lua
Normal file
@@ -0,0 +1,75 @@
|
||||
-- move selection in visual mode
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
||||
-- yank to clipboard
|
||||
vim.keymap.set("n", "<leader>y", "\"+y")
|
||||
vim.keymap.set("v", "<leader>y", "\"+y")
|
||||
vim.keymap.set("n", "<leader>Y", "\"+Y")
|
||||
|
||||
-- paste without copy
|
||||
vim.keymap.set("x", "<leader>p", "\"_dP")
|
||||
|
||||
-- delete without copy
|
||||
vim.keymap.set("n", "<leader>d", "\"_d");
|
||||
vim.keymap.set("v", "<leader>d", "\"_d");
|
||||
|
||||
-- search and replace hovered word
|
||||
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
||||
|
||||
-- make file executable
|
||||
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", {silent = true})
|
||||
|
||||
-- insert shebang on top of file
|
||||
vim.keymap.set("n", "<leader>sb", function ()
|
||||
local filetype = vim.bo.filetype
|
||||
local mapping = {
|
||||
jl = "julia",
|
||||
julia = "julia",
|
||||
sh = "bash",
|
||||
zsh = "zsh",
|
||||
py = "/usr/bin/env python3",
|
||||
python = "/usr/bin/env python3",
|
||||
}
|
||||
local command = mapping[filetype]
|
||||
if (command == nil) then return end
|
||||
-- local handle = assert(io.popen(string.format("/bin/zsh -c \"where %s\"", command)))
|
||||
-- local result = (handle:lines())()
|
||||
-- handle:close()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
-- print(result)
|
||||
vim.api.nvim_buf_set_lines(buf, 0, 0, true, { "#!" .. command })
|
||||
vim.api.nvim_command('write')
|
||||
local filename = vim.api.nvim_buf_get_name(0)
|
||||
assert(io.popen(string.format("/usr/bin/chmod +x \"%s\"", filename)))
|
||||
end)
|
||||
|
||||
-- window switching
|
||||
vim.keymap.set("n", "<C-h>", "<cmd>wincmd h<CR>")
|
||||
vim.keymap.set("n", "<C-j>", "<cmd>wincmd j<CR>")
|
||||
vim.keymap.set("n", "<C-k>", "<cmd>wincmd k<CR>")
|
||||
vim.keymap.set("n", "<C-l>", "<cmd>wincmd l<CR>")
|
||||
|
||||
-- window movement
|
||||
vim.keymap.set("n", "<C-Left>", "<cmd>wincmd H<CR>")
|
||||
vim.keymap.set("n", "<C-Right>", "<cmd>wincmd L<CR>")
|
||||
vim.keymap.set("n", "<C-Up>", "<cmd>wincmd K<CR>")
|
||||
vim.keymap.set("n", "<C-Down>", "<cmd>wincmd J<CR>")
|
||||
vim.keymap.set("n", "<C-r>", "<cmd>wincmd r<CR>")
|
||||
|
||||
-- lsp
|
||||
vim.keymap.set("n", "<F4>", vim.lsp.buf.code_action)
|
||||
vim.keymap.set("n", "<F3>", vim.lsp.buf.format)
|
||||
vim.keymap.set("n", "<leader>gD", vim.lsp.buf.declaration)
|
||||
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition)
|
||||
vim.keymap.set("n", "<leader>gt", vim.lsp.buf.type_definition)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover)
|
||||
vim.keymap.set("n", "<leader>ls", vim.lsp.buf.document_symbol)
|
||||
vim.keymap.set("n", "<leader>li", vim.lsp.buf.implementation)
|
||||
vim.keymap.set("n", "<leader>lr", vim.lsp.buf.references)
|
||||
vim.keymap.set("n", "<F2>", vim.lsp.buf.rename)
|
||||
vim.keymap.set("n", "<leader>sh", vim.lsp.buf.signature_help)
|
||||
vim.keymap.set("n", "<leader>do", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "<leader>dn", function() vim.diagnostic.jump({count=1, float=true}) end)
|
||||
vim.keymap.set("n", "<leader>dp", function() vim.diagnostic.jump({count=-1, float=true}) end)
|
||||
|
||||
35
lua/config/lazy.lua
Normal file
35
lua/config/lazy.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- Make sure to setup `mapleader` and `maplocalleader` before
|
||||
-- loading lazy.nvim so that mappings are correct.
|
||||
-- This is also a good place to setup other settings (vim.opt)
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = "\\"
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- import your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
-- Configure any other settings here. See the documentation for more details.
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
install = { colorscheme = { "habamax" } },
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = true },
|
||||
})
|
||||
40
lua/config/vars.lua
Normal file
40
lua/config/vars.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
vim.opt.nu = true
|
||||
vim.opt.relativenumber = false
|
||||
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.expandtab = true
|
||||
|
||||
vim.opt.smartindent = true
|
||||
|
||||
vim.opt.wrap = false
|
||||
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.local/share/nvim/undodir"
|
||||
vim.opt.undofile = true
|
||||
|
||||
vim.opt.hlsearch = true
|
||||
vim.opt.incsearch = true
|
||||
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.isfname:append("@-@")
|
||||
|
||||
vim.opt.updatetime = 50
|
||||
|
||||
vim.opt.conceallevel = 1
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = ","
|
||||
|
||||
-- set python path
|
||||
vim.g.python3_host_prog = os.getenv("HOME") .. "/.micromamba/envs/nvim/bin/python"
|
||||
|
||||
-- disable mouse
|
||||
vim.opt.mouse = ""
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
Reference in New Issue
Block a user