refactor: restructure the neovim config
This commit is contained in:
parent
c334e3699f
commit
bf51ebd503
13 changed files with 185 additions and 127 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
backup/*
|
14
Makefile
14
Makefile
|
@ -1,7 +1,13 @@
|
||||||
.PHONY: install_config install_packer
|
.PHONY: backup clean update install_packer
|
||||||
|
|
||||||
install_config:
|
backup:
|
||||||
@./helpers/install-neovim-config.sh
|
@bash ./helpers/config backup
|
||||||
|
|
||||||
|
update:
|
||||||
|
@bash ./helpers/config update
|
||||||
|
|
||||||
|
clean: backup
|
||||||
|
@bash ./helpers/config clean
|
||||||
|
|
||||||
install_packer:
|
install_packer:
|
||||||
@./helpers/install-plugins.sh
|
@bash ./helpers/nvim-packer
|
||||||
|
|
54
helpers/config
Executable file
54
helpers/config
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$( cd "$( dirname $0 )/.." && pwd )"
|
||||||
|
NEOVIM_CONFIG_SOURCE_DIR="${ROOT_DIR}/neovim"
|
||||||
|
NEOVIM_CONFIG_DESTINATION_DIR="${XDG_CONFIG_HOME}/nvim"
|
||||||
|
|
||||||
|
action="$1"
|
||||||
|
|
||||||
|
function backup {
|
||||||
|
if [ -d "${NEOVIM_CONFIG_DESTINATION_DIR}" ]; then
|
||||||
|
echo "INFO: backing up existing config..."
|
||||||
|
timestamp=$( date +"%Y.%m.%dT%H.%M.%S" )
|
||||||
|
backup_dir="${ROOT_DIR}/backup"
|
||||||
|
mkdir -p ${backup_dir}
|
||||||
|
cd ${NEOVIM_CONFIG_DESTINATION_DIR}
|
||||||
|
tar czf "${backup_dir}/neovim-config-${timestamp}.tar.gz" .
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean {
|
||||||
|
rm -f ${NEOVIM_CONFIG_DESTINATION_DIR}/init.lua
|
||||||
|
find ${NEOVIM_CONFIG_DESTINATION_DIR} -maxdepth 1 -mindepth 1 -type d -not -iwholename "*/plugin" | xargs rm -rf
|
||||||
|
}
|
||||||
|
|
||||||
|
function update {
|
||||||
|
mkdir -p ${NEOVIM_CONFIG_DESTINATION_DIR}
|
||||||
|
|
||||||
|
# Syncing the neovim configuration files
|
||||||
|
echo "INFO: syncing ${NEOVIM_CONFIG_SOURCE_DIR} to ${NEOVIM_CONFIG_DESTINATION_DIR}..."
|
||||||
|
rsync -avh ${NEOVIM_CONFIG_SOURCE_DIR}/ ${NEOVIM_CONFIG_DESTINATION_DIR}
|
||||||
|
chmod a-rwx,u+rwx ${NEOVIM_CONFIG_DESTINATION_DIR}
|
||||||
|
|
||||||
|
# Ensuring the data directories are present
|
||||||
|
mkdir -p ${XDG_DATA_HOME}/nvim/{backup,swap,undo,view,spell}
|
||||||
|
chmod 0700 ${XDG_DATA_HOME}/nvim/{backup,swap,undo,view,spell}
|
||||||
|
}
|
||||||
|
|
||||||
|
case ${action} in
|
||||||
|
backup)
|
||||||
|
backup
|
||||||
|
;;
|
||||||
|
clean)
|
||||||
|
clean
|
||||||
|
;;
|
||||||
|
update)
|
||||||
|
update
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unknown action ${action}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
ROOT_DIR="$( cd "$( dirname $0 )/.." && pwd )"
|
|
||||||
NEOVIM_CONFIG_SOURCE_DIR="${ROOT_DIR}/neovim"
|
|
||||||
NEOVIM_CONFIG_DESTINATION_DIR="${XDG_CONFIG_HOME}/nvim"
|
|
||||||
|
|
||||||
mkdir -p ${NEOVIM_CONFIG_DESTINATION_DIR}
|
|
||||||
|
|
||||||
# Syncing the neovim configuration files
|
|
||||||
echo "INFO: syncing ${NEOVIM_CONFIG_SOURCE_DIR} to ${NEOVIM_CONFIG_DESTINATION_DIR}"
|
|
||||||
rsync -avh ${NEOVIM_CONFIG_SOURCE_DIR}/ ${NEOVIM_CONFIG_DESTINATION_DIR}
|
|
||||||
chmod a-rwx,u+rwx ${NEOVIM_CONFIG_DESTINATION_DIR}
|
|
||||||
|
|
||||||
# Ensuring the data directories are present
|
|
||||||
mkdir -p ${XDG_DATA_HOME}/nvim/{backup,swap,undo,view,spell}
|
|
||||||
chmod 0700 ${XDG_DATA_HOME}/nvim/{backup,swap,undo,view,spell}
|
|
|
@ -1,8 +0,0 @@
|
||||||
return require("packer").startup(function(use)
|
|
||||||
-- Packer can manage itself
|
|
||||||
use "wbthomason/packer.nvim"
|
|
||||||
|
|
||||||
use "folke/tokyonight.nvim"
|
|
||||||
use "neovim/nvim-lspconfig"
|
|
||||||
use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }
|
|
||||||
end)
|
|
|
@ -1,2 +0,0 @@
|
||||||
local statusline = require("statusline")
|
|
||||||
vim.opt.statusline = statusline.output()
|
|
|
@ -1,67 +1,7 @@
|
||||||
local set = vim.opt
|
require("plugins")
|
||||||
local g = vim.g
|
require("options")
|
||||||
local cmd = vim.cmd
|
require("keybindings")
|
||||||
|
|
||||||
g.mapleader = ","
|
-- load the status line
|
||||||
|
local statusline = require("statusline")
|
||||||
-- Backups, Undos and Swaps
|
vim.opt.statusline = statusline.output()
|
||||||
set.backup = true
|
|
||||||
set.writebackup = true
|
|
||||||
set.backupdir = vim.fn.stdpath("data").."/backup"
|
|
||||||
set.swapfile = true
|
|
||||||
set.directory = vim.fn.stdpath("data").."/swap"
|
|
||||||
set.undofile = true
|
|
||||||
set.undodir = vim.fn.stdpath("data").."/undo"
|
|
||||||
set.viewdir = vim.fn.stdpath("data").."/view"
|
|
||||||
set.spellfile = vim.fn.stdpath("data").."/spell/en.utf-8.add"
|
|
||||||
|
|
||||||
-- Searching
|
|
||||||
set.ignorecase = true -- ignore case when searching.
|
|
||||||
set.smartcase = true -- override ignorecase when upper case characters are used when searching.
|
|
||||||
set.incsearch = true -- set incremental searching.
|
|
||||||
|
|
||||||
-- Default tabs and spaces
|
|
||||||
set.expandtab = true -- turn tabs into spaces
|
|
||||||
set.tabstop = 2 -- number of spaces per tab
|
|
||||||
set.softtabstop = 2 -- number of spaces per tab while editing
|
|
||||||
set.shiftwidth = 2 -- specifies the amount of whitespaces to insert/remove using indentation commands in normal mode.
|
|
||||||
|
|
||||||
-- File format and encoding
|
|
||||||
set.fileformat = "unix"
|
|
||||||
set.encoding = "utf-8"
|
|
||||||
set.fileencoding = "utf-8"
|
|
||||||
set.fileencodings = "utf-8"
|
|
||||||
|
|
||||||
-- Colour scheme
|
|
||||||
set.termguicolors = true
|
|
||||||
set.background = "dark"
|
|
||||||
g.tokyonight_style = "night"
|
|
||||||
g.tokyonight_sidebars = {"packer", "terminal"}
|
|
||||||
cmd "colorscheme tokyonight"
|
|
||||||
|
|
||||||
-- UI and UX
|
|
||||||
set.number = true -- enable line numbers
|
|
||||||
set.relativenumber = true -- enable releative line numbers
|
|
||||||
set.lazyredraw = true -- do not redraw screen when executing macros, registers, etc that have not been typed
|
|
||||||
set.splitright = true -- split vertical windows to the right
|
|
||||||
set.splitbelow = true -- split horizontal windows below
|
|
||||||
g.pastetoggle = "<F3>" -- Use <F3> to toggle paste/nopaste
|
|
||||||
set.confirm = true -- raise a dialogue to confirm if you wish to save a file before continuing.
|
|
||||||
set.cmdheight = 2 -- set the height of the command window to 2 lines.
|
|
||||||
set.modelines = 5 -- the first 5 lines are checked for modelines.
|
|
||||||
set.cursorline = true -- highlight the line that the cursor is on
|
|
||||||
set.smartindent = true -- smart autoidenting
|
|
||||||
set.scrolloff = 5
|
|
||||||
set.signcolumn = "number"
|
|
||||||
set.completeopt = "longest,menuone"
|
|
||||||
|
|
||||||
-- Netrw settings
|
|
||||||
g.netrw_banner = 0 -- disable the banner
|
|
||||||
g.netrw_liststyle = 3 -- display files and folders in a tree style
|
|
||||||
g.netrw_browse_split = 2 -- open files in a vertical split by default
|
|
||||||
g.netrw_altv = 1 -- open split to the right
|
|
||||||
g.netrw_winsize = 10 -- set the size of the Explorer window
|
|
||||||
g.netrw_keepdir = 0 -- keep the browsing directory the same as the current directory
|
|
||||||
|
|
||||||
--- Configure Omnifunc to use the LSP client.
|
|
||||||
set.omnifunc = "v:lua.vim.lsp.omnifunc"
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
local custom_attach = function(client, bufnr)
|
local custom_attach = function(client, bufnr)
|
||||||
local function buf_set_keymap(...)
|
local function buf_set_keymap(...)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function buf_set_option(...)
|
local function buf_set_option(...)
|
||||||
|
@ -57,45 +57,45 @@ require("lspconfig").golangci_lint_ls.setup{}
|
||||||
-- Terraform
|
-- Terraform
|
||||||
require("lspconfig").terraformls.setup{
|
require("lspconfig").terraformls.setup{
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
cmd = {"terraform-ls", "serve"},
|
cmd = {"terraform-ls", "serve"},
|
||||||
filetypes = {"terraform", "hcl", "tf"},
|
filetypes = {"terraform", "hcl", "tf"},
|
||||||
root_dir = require("lspconfig").util.root_pattern{".terraform", ".git", "main.tf"},
|
root_dir = require("lspconfig").util.root_pattern{".terraform", ".git", "main.tf"},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Python
|
-- Python
|
||||||
require("lspconfig").pylsp.setup{
|
require("lspconfig").pylsp.setup{
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
cmd = { "pylsp" },
|
cmd = { "pylsp" },
|
||||||
filetypes = { "python" },
|
filetypes = { "python" },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Lua
|
-- Lua
|
||||||
HOME = vim.fn.expand('$HOME')
|
local sumneko_root_path = vim.fn.expand('$HOME') .. "/Git/github.com/sumneko/lua-language-server"
|
||||||
local sumneko_root_path = HOME .. "/Git/github.com/sumneko/lua-language-server"
|
|
||||||
local sumneko_binary = sumneko_root_path .. "/bin/Linux/lua-language-server"
|
local sumneko_binary = sumneko_root_path .. "/bin/Linux/lua-language-server"
|
||||||
|
|
||||||
require'lspconfig'.sumneko_lua.setup {
|
require("lspconfig").sumneko_lua.setup {
|
||||||
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
|
on_attach = custom_attach,
|
||||||
settings = {
|
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
|
||||||
Lua = {
|
settings = {
|
||||||
runtime = {
|
Lua = {
|
||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
runtime = {
|
||||||
version = 'LuaJIT',
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||||
-- Setup your lua path
|
version = 'LuaJIT',
|
||||||
path = vim.split(package.path, ';')
|
-- Setup your lua path
|
||||||
},
|
path = vim.split(package.path, ';')
|
||||||
diagnostics = {
|
},
|
||||||
-- Get the language server to recognize the vim and awesome globals
|
diagnostics = {
|
||||||
globals = {'vim', 'awesome'}
|
-- Get the language server to recognize the vim and awesome globals
|
||||||
},
|
globals = {'vim', 'awesome'}
|
||||||
workspace = {
|
},
|
||||||
-- Make the server aware of Neovim runtime files
|
workspace = {
|
||||||
library = vim.api.nvim_get_runtime_file("", true),
|
-- Make the server aware of Neovim runtime files
|
||||||
},
|
library = vim.api.nvim_get_runtime_file("", true),
|
||||||
telemetry = {
|
},
|
||||||
-- Do not send telemetry data containing a randomized but unique identifier
|
telemetry = {
|
||||||
enable = false,
|
-- Do not send telemetry data containing a randomized but unique identifier
|
||||||
},
|
enable = false,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@ require("nvim-treesitter.configs").setup {
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
"bash",
|
"bash",
|
||||||
"go",
|
"go",
|
||||||
|
"gomod",
|
||||||
"hcl",
|
"hcl",
|
||||||
"json",
|
"json",
|
||||||
"lua",
|
"lua",
|
67
neovim/lua/options.lua
Normal file
67
neovim/lua/options.lua
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
local set = vim.opt
|
||||||
|
local g = vim.g
|
||||||
|
local cmd = vim.cmd
|
||||||
|
|
||||||
|
g.mapleader = ","
|
||||||
|
|
||||||
|
-- Backups, Undos and Swaps
|
||||||
|
set.backup = true
|
||||||
|
set.writebackup = true
|
||||||
|
set.backupdir = vim.fn.stdpath("data").."/backup"
|
||||||
|
set.swapfile = true
|
||||||
|
set.directory = vim.fn.stdpath("data").."/swap"
|
||||||
|
set.undofile = true
|
||||||
|
set.undodir = vim.fn.stdpath("data").."/undo"
|
||||||
|
set.viewdir = vim.fn.stdpath("data").."/view"
|
||||||
|
set.spellfile = vim.fn.stdpath("data").."/spell/en.utf-8.add"
|
||||||
|
|
||||||
|
-- Searching
|
||||||
|
set.ignorecase = true -- ignore case when searching.
|
||||||
|
set.smartcase = true -- override ignorecase when upper case characters are used when searching.
|
||||||
|
set.incsearch = true -- set incremental searching.
|
||||||
|
|
||||||
|
-- Default tabs and spaces
|
||||||
|
set.expandtab = true -- turn tabs into spaces
|
||||||
|
set.tabstop = 2 -- number of spaces per tab
|
||||||
|
set.softtabstop = 2 -- number of spaces per tab while editing
|
||||||
|
set.shiftwidth = 2 -- specifies the amount of whitespaces to insert/remove using indentation commands in normal mode.
|
||||||
|
|
||||||
|
-- File format and encoding
|
||||||
|
set.fileformat = "unix"
|
||||||
|
set.encoding = "utf-8"
|
||||||
|
set.fileencoding = "utf-8"
|
||||||
|
set.fileencodings = "utf-8"
|
||||||
|
|
||||||
|
-- Colour scheme
|
||||||
|
set.termguicolors = true
|
||||||
|
set.background = "dark"
|
||||||
|
g.tokyonight_style = "night"
|
||||||
|
g.tokyonight_sidebars = {"packer", "terminal"}
|
||||||
|
cmd "colorscheme tokyonight"
|
||||||
|
|
||||||
|
-- UI and UX
|
||||||
|
set.number = true -- enable line numbers
|
||||||
|
set.relativenumber = true -- enable releative line numbers
|
||||||
|
set.lazyredraw = true -- do not redraw screen when executing macros, registers, etc that have not been typed
|
||||||
|
set.splitright = true -- split vertical windows to the right
|
||||||
|
set.splitbelow = true -- split horizontal windows below
|
||||||
|
g.pastetoggle = "<F3>" -- Use <F3> to toggle paste/nopaste
|
||||||
|
set.confirm = true -- raise a dialogue to confirm if you wish to save a file before continuing.
|
||||||
|
set.cmdheight = 2 -- set the height of the command window to 2 lines.
|
||||||
|
set.modelines = 5 -- the first 5 lines are checked for modelines.
|
||||||
|
set.cursorline = true -- highlight the line that the cursor is on
|
||||||
|
set.smartindent = true -- smart autoidenting
|
||||||
|
set.scrolloff = 5
|
||||||
|
set.signcolumn = "number"
|
||||||
|
set.completeopt = "longest,menuone"
|
||||||
|
|
||||||
|
-- Netrw settings
|
||||||
|
g.netrw_banner = 0 -- disable the banner
|
||||||
|
g.netrw_liststyle = 3 -- display files and folders in a tree style
|
||||||
|
g.netrw_browse_split = 2 -- open files in a vertical split by default
|
||||||
|
g.netrw_altv = 1 -- open split to the right
|
||||||
|
g.netrw_winsize = 10 -- set the size of the Explorer window
|
||||||
|
g.netrw_keepdir = 0 -- keep the browsing directory the same as the current directory
|
||||||
|
|
||||||
|
--- Configure Omnifunc to use the LSP client.
|
||||||
|
set.omnifunc = "v:lua.vim.lsp.omnifunc"
|
17
neovim/lua/plugins.lua
Normal file
17
neovim/lua/plugins.lua
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
return require("packer").startup(function(use)
|
||||||
|
-- Packer can manage itself
|
||||||
|
use "wbthomason/packer.nvim"
|
||||||
|
|
||||||
|
use "folke/tokyonight.nvim"
|
||||||
|
|
||||||
|
use {
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
config = require("config.lsp"),
|
||||||
|
}
|
||||||
|
|
||||||
|
use {
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
config = require("config.treesitter"),
|
||||||
|
run = ":TSUpdate",
|
||||||
|
}
|
||||||
|
end)
|
Loading…
Reference in a new issue