Browse Source

initial neovim config

master
Julian Noble 2 years ago
commit
69da6d2484
  1. 1
      README.md
  2. 12
      after/plugin/fugitive.lua
  3. 3
      after/plugin/gruvbox.lua
  4. 9
      after/plugin/harpoon.lua
  5. 15
      after/plugin/lualine.lua
  6. 38
      after/plugin/mason_lsp_config.lua
  7. 7
      after/plugin/nvim-tree.lua
  8. 13
      after/plugin/telescope.lua
  9. 2
      after/plugin/undotree.lua
  10. 3
      init.lua
  11. 21
      lua/julz/globals.lua
  12. 6
      lua/julz/init.lua
  13. 48
      lua/julz/packer.lua
  14. 50
      lua/julz/remap.lua
  15. 32
      lua/julz/set.lua
  16. 67
      lua/julz/utils.lua
  17. 159
      plugin/packer_compiled.lua

1
README.md

@ -0,0 +1 @@
neovim configuration

12
after/plugin/fugitive.lua

@ -0,0 +1,12 @@
local keymap = vim.keymap
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
vim.keymap.set("n", "<leader>ga", vim.cmd.Gwrite, { desc = "Git add" })
vim.keymap.set("n", "<leader>gd", vim.cmd.Gdiffsplit)
keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git pull"})
keymap.set("n", "<leader>gpu", "<cmd>15 split | term git push<cr>", {desc = "Git push" })
-- convert git to Git in command line mode
-- vim.fn['utils#Cabbrev']('git', 'Git')

3
after/plugin/gruvbox.lua

@ -0,0 +1,3 @@
vim.o.termguicolors = true
vim.cmd [[ colorscheme gruvbox ]]

9
after/plugin/harpoon.lua

@ -0,0 +1,9 @@
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<C-h>", function() ui.nav_file(1) end)
vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end)

15
after/plugin/lualine.lua

@ -0,0 +1,15 @@
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'gruvbox',
},
sections = {
lualine_a = {
{
'filename',
path = 1,
}
}
}
}

38
after/plugin/mason_lsp_config.lua

@ -0,0 +1,38 @@
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = { "sumneko_lua" }
})
local on_attach = function(_,_)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, {})
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, {})
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {})
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, {})
vim.keymap.set('n', 'gr', require('telescope.builtin').lsp_references, {})
vim.keymap.set('n', 'K', vim.lsp.buf.hover, {})
end
require("lspconfig").sumneko_lua.setup({
on_attach = on_attach,
settings = {
Lua = {
runtime = {
version = 'LuaJIT',
},
diagnostics = {
globals = {'vim'},
},
telemetry = {
enable = false,
},
},
},
})
require("lspconfig").elixirls.setup({
on_attach = on_attach,
cmd = {"C:/users/sleek/AppData/Roaming/elixir-ls/language_server.bat"},
})

7
after/plugin/nvim-tree.lua

@ -0,0 +1,7 @@
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
require("nvim-tree").setup()
vim.keymap.set('n', '<c-n>', ':NvimTreeFindFileToggle<CR>')

13
after/plugin/telescope.lua

@ -0,0 +1,13 @@
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set('n', '<leader><leader>', builtin.oldfiles, {})
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
vim.keymap.set('n', '<leader>ps', function()
builtin.grep_string({ search = vim.fn.input("Grep > ") });
end)
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})

2
after/plugin/undotree.lua

@ -0,0 +1,2 @@
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)

3
init.lua

@ -0,0 +1,3 @@
require("julz")
-- print("Hello from init.lua")

21
lua/julz/globals.lua

@ -0,0 +1,21 @@
local fn = vim.fn
local utils = require("julz.utils")
vim.g.is_win = (utils.has("win32") or utils.has("win64")) and true or false
vim.is_linux = (utils.has("unix") and (not utils.has("macunix"))) and true or false
vim.g.is_bsd = (jit.os == "BSD") and true or false
if vim.g.is_bsd then
print("OS is BSD. nvim version:" .. utils.get_nvim_version())
end
if vim.g.is_win then
print("OS is Windows. nvim version:" .. utils.get_nvim_version())
end
if vim.g.is_linux then
print("OS is Linux. nvim version:" .. utils.get_nvim_version())
end

6
lua/julz/init.lua

@ -0,0 +1,6 @@
require("julz.globals")
require("julz.remap")
require("julz.set")
-- print("hello from julz")

48
lua/julz/packer.lua

@ -0,0 +1,48 @@
-- This file can be loaded by calling `lua require('plugins')` from your init.vim
-- Only required if you have packer configured as `opt`
vim.cmd [[packadd packer.nvim]]
return require('packer').startup(function(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'
use {
'nvim-telescope/telescope.nvim', tag = '0.1.0',
-- or , branch = '0.1.x',
requires = { {'nvim-lua/plenary.nvim'} }
}
-- use({
-- 'rose-pine/neovim',
-- as = 'rose-pine',
-- config = function()
-- vim.cmd('colorscheme rose-pine')
-- end
-- })
use 'ellisonleao/gruvbox.nvim'
use({
'nvim-tree/nvim-tree.lua',
})
use 'nvim-tree/nvim-web-devicons'
use 'nvim-lualine/lualine.nvim'
--use 'nvim-treesitter/nvim-treesitter'
--use( 'nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'} )
use( 'tpope/vim-fugitive')
use {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig"
}
use( 'theprimeagen/harpoon' )
use( 'mbbill/undotree' )
end)

50
lua/julz/remap.lua

@ -0,0 +1,50 @@
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set("n", "<leader>u", ":Undotreeshow<CR>")
-- Save key strokes (don't require shift to enter command mode)
vim.keymap.set({ "n", "x"}, ";", ":")
-- Turn word under cursor to upper case
vim.keymap.set("i", "<c-u>", "<Esc>viwUea")
-- Turn the current word into title case
vim.keymap.set("i", "<c-t>", "<Esc>b~lea")
vim.keymap.set("n", "<leader>cd", "<cmd>lcd %:p:h<cr><cmd>pwd<cr>", {desc = "change cwd"})
-- Switch windows
vim.keymap.set("n", "<Left>", "<c-w>h")
vim.keymap.set("n", "<Right>", "<c-w>l")
vim.keymap.set("n", "<Up>", "<c-w>k")
vim.keymap.set("n", "<Down>", "<c-w>j")
-- Go to start and end of current line quickly (when in insert mode)
vim.keymap.set({"n", "i"}, "<C-A>", "<HOME>")
vim.keymap.set({"n","i"}, "<C-Z>", "<END>")
-- Go to start of command in command-line mode
vim.keymap.set("c", "<C-A>", "<HOME>")
vim.keymap.set("n", "<leader>cb", function()
local cnt = 0
local blink_times = 7
local timer = vim.loop.new_timer()
timer:start(0, 100, vim.schedule_wrap(function()
vim.cmd[[
set cursorcolumn!
set cursorline!
]]
if cnt == blink_times then
timer:close()
end
cnt = cnt + 1
end))
end)

32
lua/julz/set.lua

@ -0,0 +1,32 @@
--vim.opt.guicursor = ""
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.wrap = false
vim.opt.backspace = '2'
vim.opt.showcmd = true
vim.opt.laststatus = 2
-- use spaces for tabs etc
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.shiftround = true
vim.opt.expandtab = true
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME").. "/.neovim/undodir"
vim.opt.undofile = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")
vim.opt.updatetime = 50
vim.opt.colorcolumn = "80"

67
lua/julz/utils.lua

@ -0,0 +1,67 @@
local fn = vim.fn
local M = {}
function M.executable(name)
if fn.executable(name) > 0 then
return true
end
return false
end
--- check whether a feature exists in Nvim
--- @feat: string
--- the feature name, like `nvim-0.7` or `unix`.
--- return: bool
M.has = function(feat)
if fn.has(feat) == 1 then
return true
end
return false
end
--- Create a dir if it does not exist
function M.may_create_dir(dir)
local res = fn.isdirectory(dir)
if res == 0 then
fn.mkdir(dir, "p")
end
end
function M.get_nvim_version()
local actual_ver = vim.version()
local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch)
return nvim_ver_str
end
--- Generate random integers in the range [Low, High], inclusive,
--- adapted from https://stackoverflow.com/a/12739441/6064933
--- @low: the lower value for this range
--- @high: the upper value for this range
function M.rand_int(low, high)
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
math.randomseed(os.time())
return math.random(low, high)
end
--- Select a random element from a sequence/list.
--- @seq: the sequence to choose an element
function M.rand_element(seq)
local idx = M.rand_int(1, #seq)
return seq[idx]
end
function M.add_pack(name)
local status, error = pcall(vim.cmd, "packadd " .. name)
return status
end
return M

159
plugin/packer_compiled.lua

@ -0,0 +1,159 @@
-- Automatically generated packer.nvim plugin loader code
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end
vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
_G._packer = _G._packer or {}
_G._packer.inside_compile = true
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
if threshold then
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
end
_G._packer.profile_output = results
end
time([[Luarocks path setup]], true)
local package_path_str = "C:\\Users\\sleek\\AppData\\Local\\Temp\\nvim\\packer_hererocks\\2.1.0-beta3\\share\\lua\\5.1\\?.lua;C:\\Users\\sleek\\AppData\\Local\\Temp\\nvim\\packer_hererocks\\2.1.0-beta3\\share\\lua\\5.1\\?\\init.lua;C:\\Users\\sleek\\AppData\\Local\\Temp\\nvim\\packer_hererocks\\2.1.0-beta3\\lib\\luarocks\\rocks-5.1\\?.lua;C:\\Users\\sleek\\AppData\\Local\\Temp\\nvim\\packer_hererocks\\2.1.0-beta3\\lib\\luarocks\\rocks-5.1\\?\\init.lua"
local install_cpath_pattern = "C:\\Users\\sleek\\AppData\\Local\\Temp\\nvim\\packer_hererocks\\2.1.0-beta3\\lib\\lua\\5.1\\?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
["gruvbox.nvim"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\gruvbox.nvim",
url = "https://github.com/ellisonleao/gruvbox.nvim"
},
harpoon = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\harpoon",
url = "https://github.com/theprimeagen/harpoon"
},
["lualine.nvim"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\lualine.nvim",
url = "https://github.com/nvim-lualine/lualine.nvim"
},
["mason-lspconfig.nvim"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\mason-lspconfig.nvim",
url = "https://github.com/williamboman/mason-lspconfig.nvim"
},
["mason.nvim"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\mason.nvim",
url = "https://github.com/williamboman/mason.nvim"
},
["nvim-lspconfig"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["nvim-tree.lua"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\nvim-tree.lua",
url = "https://github.com/nvim-tree/nvim-tree.lua"
},
["nvim-web-devicons"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\nvim-web-devicons",
url = "https://github.com/nvim-tree/nvim-web-devicons"
},
["packer.nvim"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["plenary.nvim"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["telescope.nvim"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
undotree = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\undotree",
url = "https://github.com/mbbill/undotree"
},
["vim-fugitive"] = {
loaded = true,
path = "C:\\Users\\sleek\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\vim-fugitive",
url = "https://github.com/tpope/vim-fugitive"
}
}
time([[Defining packer_plugins]], false)
_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then
vim.cmd("doautocmd BufRead")
end
_G._packer.needs_bufread = false
if should_profile then save_profiles() end
end)
if not no_errors then
error_msg = error_msg:gsub('"', '\\"')
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end
Loading…
Cancel
Save