Skip to content

Commit

Permalink
v0.1.0 of dotfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Dec 11, 2022
1 parent cf9f11f commit 6f06db4
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 71 deletions.
6 changes: 6 additions & 0 deletions .config/nvim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Welcome to my dotfiles

If you are new to Lua, I highly recommend checking out [Nanotee's Lua Guide](https://github.com/nanotee/nvim-lua-guide).

- you can find my plugins in ~/.config/nvim/after/plugins
- you can find my customizations in ~/.config/nvim/lua/me
64 changes: 2 additions & 62 deletions .config/nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
-- vim.g.mapleader = " "
-- vim.g.glow_binary_path = vim.env.HOME .. "/bin"
-- vim.g.glow_use_pager = true
-- vim.g.glow_border = "shadow"


local globals = {
mapleader = " ",
glow_binary_path = vim.env.HOME .. "/bin",
glow_use_pager = true,
glow_border = "shadow",
}

for k, v in pairs(globals) do
vim.g[k] = v
end

-- Aesthetic
-- pcall catches errors if the plugin doesn't load
local ok, catppuccin = pcall(require, "catppuccin")
Expand All @@ -24,52 +7,9 @@ catppuccin.setup()
vim.cmd[[colorscheme catppuccin]]

require('me.options')
require('me.globals')
require('me.lualine')
require('me.keymap')
require('me.lsp')
require('me.telescope')

local keymap = function(tbl)
local opts = { noremap = true, silent = true }
local mode = tbl['mode']
tbl['mode'] = nil
local bufnr = tbl['bufnr']
tbl['bufnr'] = nil

for k, v in pairs(tbl) do
if tonumber(k) == nil then
opts[k] = v
end
end

if bufnr ~= nil then
vim.api.nvim_buf_set_keymap(bufnr, mode, tbl[1], tbl[2], opts)
else
vim.api.nvim_set_keymap(mode, tbl[1], tbl[2], opts)
end
end

nmap = function(tbl)
tbl['mode'] = 'n'
keymap(tbl)
end

imap = function(tbl)
tbl['mode'] = 'i'
keymap(tbl)
end


local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if not ok then return end
treesitter.setup { ensure_installed = "all", highlight = { enable = true } }

-- keymaps
vim.keymap.set("n", "<leader>p", "<cmd>Glow<cr>")
nmap{"<C-f>", "<cmd>Telescope current_buffer_fuzzy_find sorting_strategy=ascending prompt_position=top<CR>"}
nmap{"<leader>lg", "<cmd>Telescope live_grep<CR>"}
nmap{"<leader>dl", "<cmd>Telescope diagnostics<cr>"}

-- navigation
nmap{"L", "<cmd>bnext<cr>"}
nmap{"H", "<cmd>bprevious<cr>"}
nmap{"F", "<cmd>HopPattern<cr>"}
10 changes: 10 additions & 0 deletions .config/nvim/lua/me/globals.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local globals = {
mapleader = " ",
glow_binary_path = vim.env.HOME .. "/bin",
glow_use_pager = true,
glow_border = "shadow",
}

for k, v in pairs(globals) do
vim.g[k] = v
end
45 changes: 45 additions & 0 deletions .config/nvim/lua/me/keymap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
local keymap = function(tbl)
local opts = { noremap = true, silent = true }
local mode = tbl['mode']
tbl['mode'] = nil
local bufnr = tbl['bufnr']
tbl['bufnr'] = nil

for k, v in pairs(tbl) do
if tonumber(k) == nil then
opts[k] = v
end
end

if bufnr ~= nil then
vim.api.nvim_buf_set_keymap(bufnr, mode, tbl[1], tbl[2], opts)
else
vim.api.nvim_set_keymap(mode, tbl[1], tbl[2], opts)
end
end

nmap = function(tbl)
tbl['mode'] = 'n'
keymap(tbl)
end

imap = function(tbl)
tbl['mode'] = 'i'
keymap(tbl)
end


local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if not ok then return end
treesitter.setup { ensure_installed = "all", highlight = { enable = true } }

-- keymaps
vim.keymap.set("n", "<leader>p", "<cmd>Glow<cr>")
nmap{"<C-f>", "<cmd>Telescope current_buffer_fuzzy_find sorting_strategy=ascending prompt_position=top<CR>"}
nmap{"<leader>lg", "<cmd>Telescope live_grep<CR>"}
nmap{"<leader>dl", "<cmd>Telescope diagnostics<cr>"}

-- navigation
nmap{"L", "<cmd>bnext<cr>"}
nmap{"H", "<cmd>bprevious<cr>"}
nmap{"F", "<cmd>HopPattern<cr>"}
136 changes: 136 additions & 0 deletions .config/nvim/lua/me/lsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
-- Native LSP Setup
require("me.keymap")
-- Global setup.
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end
},

sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' }, -- For luasnip users.
}, {
{ name = 'buffer' },
})
})

local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())

-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.settings({
ui = {
icons = {
server_installed = "",
server_pending = "",
server_uninstalled = ""
}
}
})

local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
local on_attach = function(client, bufnr)

local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end

-- Mappings.
local opts = { noremap = true, silent = true }

-- See `:help vim.lsp.*` for documentation on any of the below functions
-- leaving only what I actually use...
nmap{"K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts}
-- buf_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
nmap{"gd", "<cmd>Telescope lsp_definitions<CR>", opts}
nmap{"gr", "<cmd>Telescope lsp_references<CR>", opts}
nmap{"<C-j>", "<cmd>Telescope lsp_document_symbols<CR>", opts}
nmap{"<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts}

nmap{"gi", "<cmd>Telescope lsp_implementations<CR>", opts}
nmap{"<leader>D", "<cmd>Telescope lsp_type_definitions<CR>", opts}
nmap{"<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts}
nmap{'<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts}
nmap{"gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts}
nmap{"gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts}
nmap{"<leader>dj", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts}
nmap{"<leader>dk", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts}
nmap{"<leader>r", "<cmd>lua vim.lsp.buf.rename()<CR>", opts}

vim.cmd([[
augroup formatting
autocmd! * <buffer>
autocmd BufWritePre <buffer> lua vim.lsp.buf.format()
autocmd BufWritePre <buffer> lua OrganizeImports(1000)
augroup END
]])

-- Set autocommands conditional on server_capabilities
vim.cmd([[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]])
end

-- organize imports
-- https://github.com/neovim/nvim-lspconfig/issues/115#issuecomment-902680058
function OrganizeImports(timeoutms)
local params = vim.lsp.util.make_range_params()
params.context = { only = { "source.organizeImports" } }
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, timeoutms)
for _, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
vim.lsp.util.apply_workspace_edit(r.edit, "UTF-8")
else
vim.lsp.buf.execute_command(r.command)
end
end
end
end

lsp_installer.setup{}
local lspconfig = require('lspconfig')
lspconfig.gopls.setup {
capabilities = capabilities,
on_attach = on_attach,
settings = {
gopls = {
gofumpt = true,
},
},
flags = {
debounce_text_changes = 150,
},
}

lspconfig.golangci_lint_ls.setup {
capabilities = capabilities,
on_attach = on_attach,
settings = {
gopls = {
gofumpt = true,
},
},
flags = {
debounce_text_changes = 150,
},
}


29 changes: 29 additions & 0 deletions .config/nvim/lua/me/lualine.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require('lualine').setup{
options = {
theme = 'auto',
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff'},
lualine_c = {'buffers'},
lualine_x = {'tabs'},
lualine_y = {'progress'},
lualine_z = {
{ 'diagnostics',
sources = {'nvim_diagnostic', 'nvim_lsp'},
sections = {'error', 'warn', 'info', 'hint'},
diagnostics_color = {
-- Same values as the general color option can be used here.
error = 'DiagnosticError', -- Changes diagnostics' error color.
warn = 'DiagnosticWarn', -- Changes diagnostics' warn color.
info = 'DiagnosticInfo', -- Changes diagnostics' info color.
hint = 'DiagnosticHint', -- Changes diagnostics' hint color.
},
symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'},
colored = true, -- Displays diagnostics status in color if set to true.
update_in_insert = false, -- Update diagnostics in insert mode.
always_visible = false, -- Show diagnostics even if there are none.
}
}
}
}
21 changes: 21 additions & 0 deletions .config/nvim/lua/me/options.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local options = {
ma = true,
mouse = "a",
cursorline = true,
tabstop = 4,
shiftwidth = 4,
softtabstop = 4,
expandtab = true,
autoread = true,
nu = true,
foldlevelstart = 99,
scrolloff = 7,
backup = false,
writebackup = false,
swapfile = false,
clipboard = "unnamedplus",
}

for k, v in pairs(options) do
vim.opt[k] = v
end
22 changes: 22 additions & 0 deletions .config/nvim/lua/me/telescope.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- Telescope Setup
local action_state = require('telescope.actions.state') -- runtime (Plugin) exists somewhere as lua/telescope/actions/state.lua
require('telescope').setup{
defaults = {
prompt_prefix = "$ ",
mappings = {
i = {
["<c-a>"] = function() print(vim.inspect(action_state.get_selected_entry())) end
}
}
}
}
require('telescope').load_extension('fzf')
require('telescope').load_extension('file_browser')


local mappings = {}
mappings.curr_buf = function()
local opt = require('telescope.themes').get_dropdown({height=10, previewer=false})
require('telescope.builtin').current_buffer_fuzzy_find(opt)
end
return mappings
12 changes: 3 additions & 9 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:$CARGO
ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_MODE="nerdfont-complete"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
# ENABLE_CORRECTION="true"
# plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

source $ZSH/oh-my-zsh.sh

Expand All @@ -23,18 +23,12 @@ export EDITOR='nvim'
export PATH="$HOME/.npm/bin:$PATH"

# Aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
echo "$(cat $HOME/banner)" | lolcat
# figlet -f standard "bashbunni" | lolcat
[ -f "$HOME/.ghcup/env" ] && source "$HOME/.ghcup/env" # ghcup-env

alias dotfiles='/usr/bin/git --git-dir=$HOME/.cfg/.git --work-tree=$HOME'
alias stream='cd ~/Documents/Hobbies/'
alias bb='cd ~/Documents/bashbunni'
alias notes='cd ~/Documents/Hobbies/dev-notebook'
alias config='nvim ~/.config/nvim/init.vim'
alias luaconf='nvim ~/.config/nvim/lua/bashbunni.lua'

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
alias sourcetmux='tmux source ~/.tmux.conf'
Expand Down

0 comments on commit 6f06db4

Please sign in to comment.