Skip to content

Commit

Permalink
feat: Added init.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecollier committed Nov 9, 2023
1 parent b6c8244 commit 067e31d
Show file tree
Hide file tree
Showing 7 changed files with 1,000 additions and 142 deletions.
2 changes: 0 additions & 2 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
tap "coursier/formulas"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/core"
tap "homebrew/services"
Expand All @@ -13,7 +12,6 @@ brew "fd"
brew "fnm"
brew "fzf"
brew "jq"
brew "jsonnet"
brew "mill"
brew "neovim"
brew "nnn"
Expand Down
833 changes: 701 additions & 132 deletions Brewfile.lock.json

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions alacritty/alacritty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ font:
family: "JetBrainsMono Nerd Font"
style: Regular

size: 18.0
size: 14.0

offset:
x: 0
Expand All @@ -30,8 +30,6 @@ font:
x: 0
y: 0

use_thin_strokes: true

draw_bold_text_with_bright_colors: false

custom_cursor_colors: true
Expand All @@ -41,9 +39,6 @@ bell:
color: '0xffffff'
duration: 0

# Background opacity
background_opacity: 1.0

key_bindings:
- { key: V, mods: Command, action: Paste }
- { key: C, mods: Command, action: Copy }
Expand Down
2 changes: 1 addition & 1 deletion copy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

cp -p ~/.config/alacritty/alacritty.yml ./alacritty/alacritty.yml
cp -p ~/.config/nvim/init.vim ./neovim/init.vim
cp -p ~/.config/nvim/init.lua ./neovim/init.lua
cp -p ~/.zshrc ./zsh/zshrc
cp -p ~/.tmux.conf ./tmux/tmux.conf

1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ coursier bootstrap \
--java-opt -Xms100m \
org.scalameta:metals_2.12:0.11.2+177-fb896d65-SNAPSHOT -o metals -f

mkdir -p ~/.config/alacritty
cp -p ./alacritty/alacritty.yml ~/.config/alacritty/alacritty.yml
cp -p ./neovim/init.vim ~/.config/nvim/init.vim
cp -p ./zsh/zshrc ~/.zshrc
Expand Down
295 changes: 295 additions & 0 deletions neovim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not 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)

vim.g.mapleader = "\\"
local opt = vim.opt
opt.expandtab = true
opt.tabstop = 2
opt.softtabstop = 2
opt.shiftwidth = 2
opt.signcolumn = "yes"
opt.spell.spelllang = "en_uk"
opt.sidescroll = 1
opt.sidescrolloff = 3
opt.cursorline = true
opt.undodir = vim.fn.expand('~') .. '/.undodir/'
opt.undofile = true
vim.cmd("syntax on")
opt.list = true
opt.listchars = "tab:>-"
opt.termguicolors = true

vim.keymap.set("n", "<up>", function() vim.cmd("tabr") end)
vim.keymap.set("n", "<down>", function() vim.cmd("tabl") end)
vim.keymap.set("n", "<left>", function() vim.cmd("tabn") end)
vim.keymap.set("n", "<right>", function() vim.cmd("tabp") end)

require("lazy").setup({
{
'christoomey/vim-tmux-navigator',
'roxma/vim-tmux-clipboard',
'tmux-plugins/vim-tmux-focus-events',
'tpope/vim-surround',
'tpope/vim-commentary',
{
'rebelot/kanagawa.nvim',
config = function()
vim.cmd("colorscheme kanagawa")
end
},
'tanvirtin/vgit.nvim',
dependencies = {
'nvim-lua/plenary.nvim'
},
config = function()
vim.o.updatetime = 300
vim.o.incsearch = false
vim.wo.signcolumn = 'yes'
require('vgit').setup()
end
},
{
'mcchrish/nnn.vim',
config = function()
require("nnn").setup({})
vim.keymap.set("n", "<leader>c", function() vim.cmd("NnnPicker") end)
end
},
'nvim-lua/popup.nvim',
'nvim-lua/plenary.nvim',
'rust-lang/rust.vim',
'neovim/nvim-lsp',
'neovim/nvim-lspconfig',
{
'scalameta/nvim-metals',
ft = { "scala", "sbt", "java" },
dependencies = {
'nvim-lua/plenary.nvim'
},
init = function()
local metals_config = require("metals").bare_config()

metals_config.settings = {
showImplicitArguments = true,
showImplicitConversionsAndClasses = true,
showInferredType = true,
superMethodLensesEnabled = true,
}
metals_config.init_options.statusBarProvider = "on"
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()

local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = { "scala", "sbt", "java" },
callback = function()
require("metals").initialize_or_attach(metals_config)
end,
group = nvim_metals_group,
})
end,
},
{
'nvim-telescope/telescope.nvim',
tag = '0.1.4',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
require('telescope').setup {}
end
},
{
'folke/trouble.nvim',
dependencies = {
"nvim-tree/nvim-web-devicons",
'nvim-telescope/telescope.nvim'
},
init = function()
local trouble = require("trouble.providers.telescope")
vim.keymap.set("n", "<leader>xx", function() trouble.toggle() end)
vim.keymap.set("n", "<leader>xw", function() trouble.toggle("workspace_diagnostics") end)
vim.keymap.set("n", "<leader>xd", function() trouble.toggle("document_diagnostics") end)
vim.keymap.set("n", "<leader>xq", function() trouble.toggle("quickfix") end)
vim.keymap.set("n", "<leader>xl", function() trouble.toggle("loclist") end)
vim.keymap.set("n", "gR", function() trouble.toggle("lsp_references") end)
local actions = require("telescope.actions")

local telescope = require("telescope")

telescope.setup {
defaults = {
mappings = {
i = { ["<c-t>"] = trouble.open_with_trouble },
n = { ["<c-t>"] = trouble.open_with_trouble },
},
},
}
end
},
'vim-test/vim-test',
{
'nvim-treesitter/nvim-treesitter',
config = function()
require('nvim-treesitter.configs').setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "rust" },

-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,

-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,

-- List of parsers to ignore installing (or "all")
ignore_install = { "javascript" },

---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!

highlight = {
enable = true,

-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,

-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}
end
},
{
"L3MON4D3/LuaSnip",
version = "v2.0.0",
build = "make install_jsregexp"
},
{
'hrsh7th/nvim-cmp',
dependencies = {
'neovim/nvim-lspconfig',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'hrsh7th/nvim-cmp',
'saadparwaiz1/cmp_luasnip'
},
config = function()
-- Set up nvim-cmp.
local cmp = require 'cmp'

cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' }, -- For luasnip users.
}, {
{ name = 'buffer' },
})
})

-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, {
{ name = 'buffer' },
})
})

-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})

-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
end
},
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v3.x',
dependencies = {
'neovim/nvim-lspconfig',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/nvim-cmp',
'L3MON4D3/LuaSnip',
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
},
config = function()
local lsp_zero = require('lsp-zero')

lsp_zero.on_attach(function(client, bufnr)
lsp_zero.default_keymaps({ buffer = bufnr })
lsp_zero.buffer_autoformat()
local opts = { buffer = bufnr }
vim.keymap.set('n', 'gr', '<cmd>Telescope lsp_references<cr>', opts)
vim.keymap.set('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
end)
require('mason-lspconfig').setup({
ensure_installed = {},
handlers = {
lsp_zero.default_setup,
},
})
local lua_opts = lsp_zero.nvim_lua_ls()
require('lspconfig').lua_ls.setup(lua_opts)
end
},
{
'williamboman/mason.nvim',
config = function()
require('mason').setup({})
end
},
})
2 changes: 1 addition & 1 deletion neovim/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ Plug 'tpope/vim-rhubarb'

" Reason
Plug 'reasonml-editor/vim-reason-plus'
Plug 'tpope/vim-surround'

" Distraction free
Plug 'junegunn/goyo.vim'

" God pope
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-projectionist'
Expand Down

0 comments on commit 067e31d

Please sign in to comment.