all: Initial dotfiles
Import an initial copy of all of my dotfiles Signed-off-by: Nicholas Mello <nick@nmello.dev>
This commit is contained in:
47
nvim/.editorconfig
Normal file
47
nvim/.editorconfig
Normal file
@@ -0,0 +1,47 @@
|
||||
# EditorConfig is awesome: https://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
# Neovim Lua config files
|
||||
[*.lua]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8
|
||||
|
||||
# Vim script files
|
||||
[*.vim]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8
|
||||
|
||||
# Shell scripts
|
||||
[*.sh]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8
|
||||
|
||||
# Markdown files
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
|
||||
# Git commit messages
|
||||
[COMMIT_EDITMSG]
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
|
||||
# Generic defaults for other text files
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8
|
||||
52
nvim/init.lua
Normal file
52
nvim/init.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
vim.opt.mouse = ""
|
||||
|
||||
vim.opt.wildmode = "longest,list"
|
||||
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = "tab:>-,trail:-,extends:#,nbsp:-"
|
||||
|
||||
vim.opt.ignorecase = true -- case insensitive search
|
||||
vim.opt.smartcase = true -- case sensitive when uc present
|
||||
vim.opt.modeline = true -- Search files for local settings such as nowrap
|
||||
vim.opt.laststatus = 2 -- Always show the status line at the bottom of the window
|
||||
|
||||
vim.opt.colorcolumn = "80"
|
||||
vim.api.nvim_set_hl(0, "ColorColumn", { ctermbg = 232, bg = 232 })
|
||||
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
vim.wo.relativenumber = true
|
||||
|
||||
vim.g.mapleader = ";"
|
||||
|
||||
-- Get rid of highlighting with enter
|
||||
vim.keymap.set("n", "<cr>", "<cmd>noh<cr><cr>")
|
||||
|
||||
-- Leader Bindings
|
||||
vim.g.mapleader = ";"
|
||||
vim.keymap.set('n', '<leader>tc', '<cmd>tabnew<cr>')
|
||||
vim.keymap.set('n', '<leader>tn', '<cmd>tabnext<cr>')
|
||||
vim.keymap.set('n', '<leader>tp', '<cmd>tabprevious<cr>')
|
||||
vim.keymap.set('n', '<leader>tN', '<cmd>tabprevious<cr>')
|
||||
vim.keymap.set('n', '<leader>z', '<c-w>|<c-w>_')
|
||||
vim.keymap.set('n', '<leader><space>', '<c-w>=')
|
||||
vim.keymap.set('n', '<leader>h', '<c-w>h')
|
||||
vim.keymap.set('n', '<leader>j', '<c-w>j')
|
||||
vim.keymap.set('n', '<leader>k', '<c-w>k')
|
||||
vim.keymap.set('n', '<leader>l', '<c-w>l')
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
prefix = '>>', -- or any symbol you prefer
|
||||
spacing = 1,
|
||||
-- position diagnostics at end of line:
|
||||
virt_text_pos = "eol",
|
||||
},
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
require("bootstrap") -- Bootstrap lazy.nvim and load all plugins
|
||||
require("whitespace") -- Adds autocmd to remove whitespace
|
||||
require("jk") -- Adds jk escape
|
||||
16
nvim/lazy-lock.json
Normal file
16
nvim/lazy-lock.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
|
||||
"fzf.vim": { "branch": "master", "commit": "3725f364ccd25b85a91970720ba9bc2931861910" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
|
||||
"mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" },
|
||||
"mini.icons": { "branch": "main", "commit": "b8f6fa6f5a3fd0c56936252edcd691184e5aac0c" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "f0c6ccf43997a1c7e9ec4aea36ffbf2ddd9f15ef" },
|
||||
"oil.nvim": { "branch": "master", "commit": "bbad9a76b2617ce1221d49619e4e4b659b3c61fc" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }
|
||||
}
|
||||
74
nvim/lua/bootstrap.lua
Normal file
74
nvim/lua/bootstrap.lua
Normal file
@@ -0,0 +1,74 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
local offline_marker = vim.fn.stdpath("config") .. "/.offline"
|
||||
|
||||
-- Define your functions first
|
||||
|
||||
local function is_offline()
|
||||
return vim.fn.filereadable(offline_marker) == 1
|
||||
end
|
||||
|
||||
local function set_offline()
|
||||
local f = io.open(offline_marker, "w")
|
||||
if f then
|
||||
f:write("offline\n")
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
||||
local function clear_offline()
|
||||
os.remove(offline_marker)
|
||||
end
|
||||
|
||||
local function has_network()
|
||||
local handle = io.popen("ping -c 1 github.com 2>/dev/null")
|
||||
if handle then
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
return result and #result > 0
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function install_lazy()
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable",
|
||||
lazypath,
|
||||
})
|
||||
print("lazy.nvim installed!")
|
||||
end
|
||||
|
||||
-- Now call the functions
|
||||
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
if is_offline() then
|
||||
print("Offline mode enabled. Skipping lazy.nvim install.")
|
||||
return
|
||||
else
|
||||
if has_network() then
|
||||
install_lazy()
|
||||
clear_offline()
|
||||
else
|
||||
print("No network detected. Enabling offline mode.")
|
||||
set_offline()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require('lazy').setup({
|
||||
spec = {
|
||||
-- import your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("GoOnline", function()
|
||||
clear_offline()
|
||||
print(".offline marker cleared. Restart Neovim to attempt plugin install again.")
|
||||
end, {})
|
||||
36
nvim/lua/jk.lua
Normal file
36
nvim/lua/jk.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
local timer = nil
|
||||
local waiting_for_k = false
|
||||
|
||||
local function cancel_timer()
|
||||
if timer then
|
||||
timer:stop()
|
||||
timer:close()
|
||||
timer = nil
|
||||
end
|
||||
waiting_for_k = false
|
||||
end
|
||||
|
||||
vim.keymap.set({"i", "t"}, "j", function()
|
||||
if waiting_for_k then
|
||||
return "j"
|
||||
end
|
||||
|
||||
waiting_for_k = true
|
||||
|
||||
local timeout = vim.o.timeoutlen
|
||||
timer = vim.loop.new_timer()
|
||||
timer:start(timeout, 0, vim.schedule_wrap(function()
|
||||
cancel_timer()
|
||||
end))
|
||||
|
||||
return "j"
|
||||
end, { expr = true, noremap = true })
|
||||
|
||||
vim.keymap.set({"i", "t"}, "k", function()
|
||||
if waiting_for_k then
|
||||
cancel_timer()
|
||||
return "<BS><ESC>"
|
||||
else
|
||||
return "k"
|
||||
end
|
||||
end, { expr = true, noremap = true })
|
||||
7
nvim/lua/plugins/autopairs.lua
Normal file
7
nvim/lua/plugins/autopairs.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
return {
|
||||
'windwp/nvim-autopairs',
|
||||
event = "InsertEnter",
|
||||
config = true
|
||||
-- use opts = {} for passing setup options
|
||||
-- this is equivalent to setup({}) function
|
||||
}
|
||||
45
nvim/lua/plugins/completion.lua
Normal file
45
nvim/lua/plugins/completion.lua
Normal file
@@ -0,0 +1,45 @@
|
||||
return {
|
||||
'saghen/blink.cmp',
|
||||
dependencies = { 'rafamadriz/friendly-snippets' },
|
||||
|
||||
version = '1.*',
|
||||
|
||||
opts = {
|
||||
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
|
||||
-- 'super-tab' for mappings similar to vscode (tab to accept)
|
||||
-- 'enter' for enter to accept
|
||||
-- 'none' for no mappings
|
||||
--
|
||||
-- All presets have the following mappings:
|
||||
-- C-space: Open menu or open docs if already open
|
||||
-- C-n/C-p or Up/Down: Select next/previous item
|
||||
-- C-e: Hide menu
|
||||
-- C-k: Toggle signature help (if signature.enabled = true)
|
||||
--
|
||||
-- See :h blink-cmp-config-keymap for defining your own keymap
|
||||
keymap = { preset = 'super-tab' },
|
||||
|
||||
appearance = {
|
||||
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||
-- Adjusts spacing to ensure icons are aligned
|
||||
nerd_font_variant = 'mono'
|
||||
},
|
||||
|
||||
-- (Default) Only show the documentation popup when manually triggered
|
||||
completion = { documentation = { auto_show = false } },
|
||||
|
||||
-- Default list of enabled providers defined so that you can extend it
|
||||
-- elsewhere in your config, without redefining it, due to `opts_extend`
|
||||
sources = {
|
||||
default = { 'lsp', 'snippets', 'path', 'buffer' },
|
||||
},
|
||||
|
||||
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
||||
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
||||
--
|
||||
-- See the fuzzy documentation for more information
|
||||
fuzzy = { implementation = "prefer_rust_with_warning" }
|
||||
},
|
||||
opts_extend = { "sources.default" }
|
||||
}
|
||||
29
nvim/lua/plugins/explorer.lua
Normal file
29
nvim/lua/plugins/explorer.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
return {
|
||||
'stevearc/oil.nvim',
|
||||
---@module 'oil'
|
||||
---@type oil.SetupOpts
|
||||
opts = {
|
||||
float = {
|
||||
max_width = math.floor(vim.o.columns * 0.6),
|
||||
max_height = math.floor(vim.o.lines * 0.6),
|
||||
border = "rounded",
|
||||
}
|
||||
},
|
||||
-- Optional dependencies
|
||||
dependencies = { { "echasnovski/mini.icons", opts = {} } },
|
||||
-- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons
|
||||
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
|
||||
lazy = false,
|
||||
|
||||
keys = {
|
||||
{
|
||||
"<leader>e",
|
||||
function()
|
||||
require("oil").open_float()
|
||||
end,
|
||||
desc = "Open Oil floating window",
|
||||
noremap = true,
|
||||
silent = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
20
nvim/lua/plugins/git.lua
Normal file
20
nvim/lua/plugins/git.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
return {
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
config = function()
|
||||
require("gitsigns").setup({
|
||||
signs = {
|
||||
add = { text = "+" },
|
||||
change = { text = "~" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "~" },
|
||||
},
|
||||
numhl = false,
|
||||
linehl = false,
|
||||
watch_gitdir = { interval = 1000 }, -- auto-refresh
|
||||
attach_to_untracked = true,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
53
nvim/lua/plugins/lsp.lua
Normal file
53
nvim/lua/plugins/lsp.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
callback = function()
|
||||
vim.lsp.buf.format()
|
||||
end,
|
||||
})
|
||||
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
{
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua", -- only load on lua files
|
||||
opts = {
|
||||
library = {
|
||||
-- See the configuration section for more details
|
||||
-- Load luvit types when the `vim.uv` word is found
|
||||
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
lspconfig.lua_ls.setup {}
|
||||
|
||||
lspconfig.pyright.setup {}
|
||||
|
||||
lspconfig.bashls.setup {}
|
||||
|
||||
lspconfig.fish_lsp.setup {}
|
||||
|
||||
lspconfig.rust_analyzer.setup {
|
||||
root_dir = function(fname)
|
||||
-- Look for Cargo.toml to define project root
|
||||
return lspconfig.util.root_pattern("Cargo.toml")(fname)
|
||||
end,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
cargo = { allFeatures = true },
|
||||
checkOnSave = { command = "clippy" }, -- Run linter
|
||||
}
|
||||
}
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
-- Quickly install LSPs with internet connection
|
||||
"mason-org/mason.nvim",
|
||||
opts = {}
|
||||
},
|
||||
}
|
||||
28
nvim/lua/plugins/telescope.lua
Normal file
28
nvim/lua/plugins/telescope.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
return {
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
tag = '0.1.8',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
cmd = "Telescope",
|
||||
keys = {
|
||||
{ '<leader>f', '<cmd>Telescope find_files<cr>', mode = { "n" }, desc = "Telescope find_files" },
|
||||
{ '<leader>b', '<cmd>Telescope buffers<cr>', mode = { "n" }, desc = "Telescope buffers" },
|
||||
{ '<leader>g', '<cmd>Telescope grep_string<cr>', mode = { "n" }, desc = "Telescope grep_string" },
|
||||
{ '<leader>r', '<cmd>Telescope live_grep<cr>', mode = { "n" }, desc = "Telescope live_grep" },
|
||||
{ '<leader>;', '<cmd>Telescope<cr>', mode = { "n" }, desc = "Telescope options" },
|
||||
},
|
||||
config = {},
|
||||
},
|
||||
{
|
||||
'nvim-telescope/telescope-fzf-native.nvim',
|
||||
dependencies = {'nvim-telescope/telescope.nvim'},
|
||||
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release',
|
||||
config = function()
|
||||
require('telescope').load_extension('fzf')
|
||||
end,
|
||||
},
|
||||
{
|
||||
'junegunn/fzf.vim',
|
||||
event = "VeryLazy",
|
||||
}
|
||||
}
|
||||
12
nvim/lua/whitespace.lua
Normal file
12
nvim/lua/whitespace.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- RemoveWhitespace
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("RemoveWhitespace", { clear = true }),
|
||||
pattern = "*", -- Handle pattern myself in callback
|
||||
callback = function()
|
||||
if vim.bo.filetype == "diff" then
|
||||
return
|
||||
end
|
||||
-- Failure to find is not a real failure, silence failures
|
||||
vim.api.nvim_command("silent! " .. "%s/\\s\\+$//")
|
||||
end,
|
||||
})
|
||||
Reference in New Issue
Block a user