Skip to content

Commit

Permalink
Rewrite init.vim to init.lua. nvim
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed Jun 18, 2024
1 parent 0e004c2 commit 5da7b52
Show file tree
Hide file tree
Showing 17 changed files with 306 additions and 313 deletions.
2 changes: 1 addition & 1 deletion alacritty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ background = "0x002b36"
foreground = "0x839496"

[env]
TERM = "screen-256color"
TERM = "xterm-256color"

[font]
size = 10
Expand Down
29 changes: 0 additions & 29 deletions coc-settings.json

This file was deleted.

1 change: 1 addition & 0 deletions ftplugin/changelog.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vim.o.spell = true
2 changes: 2 additions & 0 deletions ftplugin/gitcommit.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vim.o.spell = true
vim.o.textwidth = 80
1 change: 1 addition & 0 deletions ftplugin/go.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vim.o.expandtab = false
2 changes: 2 additions & 0 deletions ftplugin/markdown.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vim.o.spell = true
vim.o.textwidth = 80
2 changes: 2 additions & 0 deletions ftplugin/plaintex.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vim.o.spell = true
vim.o.textwidth = 80
1 change: 1 addition & 0 deletions ftplugin/text.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vim.o.textwidth = 80
23 changes: 23 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- plugin manager
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)

-- nvim-tree
-- disable netrw at the very start of your init.lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

require('plugins')
require('settings')
require('lsp')
require('keymaps')
232 changes: 0 additions & 232 deletions init.vim

This file was deleted.

15 changes: 3 additions & 12 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ ln -s -f "$HOME/dotfiles/zshenv" "$HOME/.zshenv"
ln -s -f "$HOME/dotfiles/zcomp" "$HOME/.zcomp"
## vim
mkdir -p "$HOME/.config/nvim"
ln -s -f "$HOME/dotfiles/init.vim" "$HOME/.config/nvim/init.vim"
ln -s -f "$HOME/dotfiles/plugins.vim" "$HOME/.config/nvim/plugins.vim"
ln -s -f "$HOME/dotfiles/coc-settings.json" "$HOME/.config/nvim/coc-settings.json"
ln -s -f "$HOME/dotfiles/init.lua" "$HOME/.config/nvim/init.lua"
ln -s -f "$HOME/dotfiles/lua" "$HOME/.config/nvim/"
ln -s -f "$HOME/dotfiles/ftplugin" "$HOME/.config/nvim/"
ln -s -f "$HOME/dotfiles/spell" "$HOME/.config/nvim/"
ln -s -f "$HOME/dotfiles/init.vim" "$HOME/.vimrc"
ln -s -f "$HOME/dotfiles/Pipfile" "$HOME/.config/nvim/Pipfile"
## git
ln -s -f "$HOME/dotfiles/gitconfig" "$HOME/.gitconfig"
Expand All @@ -34,14 +33,6 @@ ln -s -f "$HOME/dotfiles/ripgreprc" "$HOME/.ripgreprc"

echo "Symlinks successfully created for ~/dotfiles."

# Install fonts
if ! fc-list | grep -i "Source Code Pro.*.otf" >/dev/null; then
git clone https://github.com/powerline/fonts.git "$HOME/fonts"
sh "$HOME/fonts/install.sh"
echo "Set your terminal font to 'Source Code Pro'."
rm -rf "$HOME/fonts"
fi

if command -v pipenv &> /dev/null; then
pushd "$HOME/.config/nvim" || exit 0
pipenv install
Expand Down
46 changes: 46 additions & 0 deletions lua/keymaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }

vim.g.mapleader = ','

-- Reload init.lua
map('n', '<F5>', ':luafile ~/.config/nvim/init.lua<CR>', opts)

-- Copy to clipboard
map('', '<leader>y', '"+y', opts)

-- nvim-tree
map('n', '<F8>', ':NvimTreeToggle<CR>', opts)
map('n', '<F9>', ':NvimTreeFindFile<CR>', opts)

-- fzf
map('n', '<leader>b', ':Buffer<CR>', opts)
map('n', '<leader>h', ':History<CR>', opts)
map('n', '<leader>r', ':Rg<CR>', opts)
map('n', '<leader>f', ":exe ':Rg' expand('<cword>')<CR>", opts)

-- Save/Close
map('n', '<leader>q', ':q<CR>', opts)
map('n', '<leader>w', ':update<CR>', opts)

-- Wrapped line navigation
map('n', 'j', 'gj', opts)
map('n', 'k', 'gk', opts)

-- LSP
map('n', 'gpd', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
map('n', 'gnd', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
map('n', 'gpe', '<cmd>lua vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR })<CR>', opts)
map('n', 'gne', '<cmd>lua vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR })<CR>', opts)

map('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
map('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
map('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
map('n', 'gr', ":lua require'telescope.builtin'.lsp_references{}<CR>", opts)

map('n', 'H', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
map('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)

map('n', '<leader>a', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
map('n', '<leader>t', ':ClangdSwitchSourceHeader<CR>', opts)
Loading

0 comments on commit 5da7b52

Please sign in to comment.