Compare commits

..

2 commits

Author SHA1 Message Date
738b7b1976
pin nvim-dap-go 2022-05-18 07:21:18 +01:00
6f56c29456
add nvim-dap and nvim-dap-go 2022-05-18 07:21:12 +01:00
41 changed files with 369 additions and 860 deletions

1
.gitignore vendored
View file

@ -1,2 +1 @@
backup/*
build/*

View file

@ -1,70 +1,42 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
CONFIG_ROOT="${XDG_CONFIG_HOME:-null}"
if [[ "${CONFIG_ROOT}" == "null" ]]; then
CONFIG_ROOT="${HOME}/.config"
fi
set -euo pipefail
ROOT_DIR="$( cd "$( dirname $0 )/.." && pwd )"
NEOVIM_CONFIG_SOURCE_DIR="${ROOT_DIR}/nvim"
NEOVIM_CONFIG_DESTINATION_DIR="${CONFIG_ROOT}/nvim"
VERSION="$( git describe --tags | tr -d '\n' )"
PROJECT_NAME="nvim.d"
CODEFLOW_GROUP="linux-home"
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" .
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
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 install {
mkdir -p "${NEOVIM_CONFIG_DESTINATION_DIR}"
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}"
rsync -avh ${NEOVIM_CONFIG_SOURCE_DIR}/ ${NEOVIM_CONFIG_DESTINATION_DIR}
chmod a-rwx,u+rwx ${NEOVIM_CONFIG_DESTINATION_DIR}
# Ensuring the state directories are present
mkdir -p ${XDG_STATE_HOME}/nvim/{backup,swap,undo,view} ${XDG_STATE_HOME}/logs/nvim ${XDG_DATA_HOME}/nvim/spell
chmod 0700 ${XDG_STATE_HOME}/nvim/{backup,swap,undo,view} ${XDG_STATE_HOME}/logs/nvim ${XDG_DATA_HOME}/nvim/spell
}
function package {
cd "${ROOT_DIR}"
if ! [ -d "${ROOT_DIR}/build" ]; then
mkdir "${ROOT_DIR}/build"
fi
tar czv -f "${ROOT_DIR}/build/${PROJECT_NAME}-${VERSION}.tar.gz" $( basename "${NEOVIM_CONFIG_SOURCE_DIR}" )
}
function publish {
curl --request PUT \
--user ${CODEFLOW_USERNAME}:${CODEFLOW_TOKEN} \
--upload-file build/${PROJECT_NAME}-${VERSION}.tar.gz \
https://codeflow.dananglin.me.uk/api/packages/${CODEFLOW_GROUP}/generic/${PROJECT_NAME}/${VERSION}/${PROJECT_NAME}-${VERSION}.tar.gz
}
case ${action} in
backup)
backup
@ -72,14 +44,8 @@ case ${action} in
clean)
clean
;;
install)
install
;;
package)
package
;;
publish)
publish
update)
update
;;
*)
echo "ERROR: Unknown action ${action}"

View file

@ -1,19 +0,0 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
LAZY_NVIM_SOURCE="https://github.com/folke/lazy.nvim.git"
LAZY_NVIM_DESTINATION="${XDG_DATA_HOME}/nvim/lazy/lazy.nvim"
LAZY_STATE_DIR="${XDG_STATE_HOME}/nvim/lazy"
mkdir -p ${LAZY_STATE_DIR}
if [ -d ${LAZY_NVIM_DESTINATION}/.git ]; then
echo "INFO: lazy.nvim is already installed"
exit 0
fi
echo "INFO: Cloning ${LAZY_NVIM_SOURCE} to ${LAZY_NVIM_DESTINATION}..."
git clone --filter=blob:none --single-branch ${LAZY_NVIM_SOURCE} ${LAZY_NVIM_DESTINATION}

14
.helpers/nvim-packer Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
PACKER_NVIM_SOURCE="https://github.com/wbthomason/packer.nvim"
PACKER_NVIM_DESTINATION="${XDG_DATA_HOME}/nvim/site/pack/packer/start/packer.nvim"
if [ -d ${PACKER_NVIM_DESTINATION}/.git ]; then
echo "INFO: packer.nvim is already installed."
exit 0
fi
echo "INFO: Cloning ${PACKER_NVIM_SOURCE} to ${PACKER_NVIM_DESTINATION}..."
git clone --depth=1 ${PACKER_NVIM_SOURCE} ${PACKER_NVIM_DESTINATION}

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Dan Anglin
Copyright (c) 2022 Dan Anglin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1,19 +1,13 @@
.PHONY: backup clean install install_lazy package publish
.PHONY: backup clean update install_packer
backup:
@bash ./.helpers/config backup
install:
@bash ./.helpers/config install
update:
@bash ./.helpers/config update
clean: backup
@bash ./.helpers/config clean
install_lazy:
@bash ./.helpers/lazy.nvim
package:
@bash ./.helpers/config package
publish: package
@bash ./.helpers/config publish
install_packer:
@bash ./.helpers/nvim-packer

View file

@ -1,68 +0,0 @@
= nvim.d
My neovim configuration for neovim version 0.10.0+.
== Dependencies
== Installation
1. Clone the repository or download the latest package from the release page.
2. If you have existing neovim configuration you can take a backup of it.
Run the command below to create a timestamped tar archive of your existing config.
make backup
3. Install the config to your `XDG_CONIFIG_HOME` directory (default is ~/.config).
make install
4. Install the lazy package manager.
make install_lazy
5. Launch neovim.
At first launch the lazy package manager will proceed to install all the specified plugins.
== Plugins
[%header,cols=3*]
|===
|Name
|Purpose
|Link to source
|folke/lazy.nvim
|Manages all other neovim plugins.
|https://github.com/folke/lazy.nvim
|folke/tokyonight.nvim
|Sets the Tokyonight colour scheme for neovim.
|https://github.com/folke/tokyonight.nvim
|neovim/nvim-lspconfig
|Makes configuring LSP settings in neovim much easier.
|https://github.com/neovim/nvim-lspconfig
|nvim-treesitter/nvim-treesitter
|An interface for treesitter to provide better highlighting among other functionalities.
|https://github.com/nvim-treesitter/nvim-treesitter
|akinsho/bufferline.nvim
|For visualising buffers and easy navigation between them.
|https://github.com/akinsho/bufferline.nvim
|nvim-tree/nvim-web-devicons
|Provides icons that are used in other plugins.
|https://github.com/nvim-tree/nvim-web-devicons
|is0n/tui-nvim
|Allows you to open terminal programs in neovim. Currently used to integration the LF file manager within neovim.
|https://github.com/is0n/tui-nvim
|mfussenegger/nvim-lint
|An asynchronous linter plugin complementary to the LSP client. Used for external linters such as golangci-lint and pyls.
|https://github.com/mfussenegger/nvim-lint
|===
== Key mappings

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# neovim-config
Neovim configuration for neovim version 0.7.0+.

81
ci.go
View file

@ -1,81 +0,0 @@
package main
import (
"context"
"fmt"
"os"
"path/filepath"
"dagger.io/dagger"
)
const (
envCodeFlowUsername string = "CODEFLOW_USERNAME"
envCodeFlowToken string = "CODEFLOW_TOKEN"
)
func main() {
if err := build(context.Background()); err != nil {
fmt.Printf("ERROR: %v", err)
os.Exit(1)
}
}
func build(ctx context.Context) error {
fmt.Println("Building with Dagger.")
client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stdout))
if err != nil {
return fmt.Errorf("unable to create the dagger client; %w", err)
}
defer client.Close()
rootDir, err := filepath.Abs(".")
if err != nil {
return err
}
image := "alpine:3.17"
containerWorkspace := "/workspace"
username := os.Getenv(envCodeFlowUsername)
if username == "" {
return fmt.Errorf("%s is not set", envCodeFlowUsername)
}
token := os.Getenv(envCodeFlowToken)
if token == "" {
return fmt.Errorf("%s is not set", envCodeFlowToken)
}
publisher := client.Container().
From(image).
WithMountedDirectory(containerWorkspace, client.Host().Directory(rootDir)).
WithWorkdir(containerWorkspace).
WithEnvVariable("XDG_CONFIG_HOME", "null").
WithEnvVariable("CODEFLOW_USERNAME", username).
WithEnvVariable("CODEFLOW_TOKEN", token)
publisher = setDependencies(publisher)
publisher = publish(publisher, containerWorkspace)
_, err = publisher.Stdout(ctx)
if err != nil {
return fmt.Errorf("unable to export package from container; %w", err)
}
return nil
}
func setDependencies(container *dagger.Container) *dagger.Container {
return container.WithExec([]string{
"apk", "add", "--no-cache", "bash", "curl", "git", "make",
})
}
func publish(container *dagger.Container, workspace string) *dagger.Container {
return container.
WithExec([]string{"git", "config", "--global", "--add", "safe.directory", workspace}).
WithExec([]string{"make", "publish"})
}

14
go.mod
View file

@ -1,14 +0,0 @@
module ci
go 1.19
require dagger.io/dagger v0.4.3
require (
github.com/Khan/genqlient v0.5.0 // indirect
github.com/adrg/xdg v0.4.0 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/vektah/gqlparser/v2 v2.5.1 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
)

112
go.sum
View file

@ -1,112 +0,0 @@
dagger.io/dagger v0.4.3 h1:rp+Ho/iqLAAkJkn7g9BslS3+FYLrrq1Th9fmgkk3C00=
dagger.io/dagger v0.4.3/go.mod h1:wr3lf4B+yV0CP2rQlYe5fHt0RgKicy7wxA9rBjxW0nI=
github.com/99designs/gqlgen v0.17.2/go.mod h1:K5fzLKwtph+FFgh9j7nFbRUdBKvTcGnsta51fsMTn3o=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Khan/genqlient v0.5.0 h1:TMZJ+tl/BpbmGyIBiXzKzUftDhw4ZWxQZ+1ydn0gyII=
github.com/Khan/genqlient v0.5.0/go.mod h1:EpIvDVXYm01GP6AXzjA7dKriPTH6GmtpmvTAwUUqIX8=
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/agnivade/levenshtein v1.1.0/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/alexflint/go-arg v1.4.2/go.mod h1:9iRbDxne7LcR/GSvEr7ma++GLpdIU1zrghf2y2768kM=
github.com/alexflint/go-scalar v1.0.0/go.mod h1:GpHzbCOZXEKMEcygYQ5n/aa4Aq84zbxjy3MxYW0gjYw=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/bradleyjkemp/cupaloy/v2 v2.6.0/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
github.com/matryer/moq v0.2.3/go.mod h1:9RtPYjTnH1bSBIkpvtHkFN7nbWAnO7oRpdJkEIn6UtE=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mitchellh/mapstructure v1.2.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/vektah/gqlparser/v2 v2.4.0/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0=
github.com/vektah/gqlparser/v2 v2.4.5/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0=
github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4=
github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200815165600-90abf76919f3/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

View file

@ -0,0 +1,4 @@
local setlocal = vim.opt_local
setlocal.spell = true
setlocal.spelllang = "en_gb"

View file

@ -0,0 +1,4 @@
local setlocal = vim.opt_local
setlocal.spell = true
setlocal.spelllang = "en_gb"

3
neovim/init.lua Normal file
View file

@ -0,0 +1,3 @@
require("plugins")
require("options")
require("keybindings")

View file

@ -11,6 +11,7 @@ bufferline.setup{
color_icons = true,
show_buffer_icons = true,
show_buffer_close_icons = false,
show_buffer_default_icon = true,
show_close_icon = false,
show_tab_indicators = true,
separator_style = "slant",
@ -28,9 +29,5 @@ bufferline.setup{
numbers = function(opts)
return string.format("[%s]%s", opts.id, opts.raise(opts.ordinal))
end,
get_element_icon = function(element)
local icon, hl = require('nvim-web-devicons').get_icon_by_filetype(element.filetype, { default = false })
return icon, hl
end,
}
}

View file

@ -0,0 +1,7 @@
local ok, dap_go = pcall(require, "dap-go")
if not ok then
return
end
dap_go.setup()

113
neovim/lua/config/lsp.lua Normal file
View file

@ -0,0 +1,113 @@
local ok, lspconfig = pcall(require, "lspconfig")
if not ok then
return
end
local custom_attach = function(client, bufnr)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', '<leader>h', '<Cmd>lua vim.lsp.buf.hover()<CR>', { noremap=true, silent=true })
buf_set_keymap('n', '<leader>gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', { noremap=true, silent=true })
buf_set_keymap('n', '<leader>gr', '<cmd>lua vim.lsp.buf.references()<CR>', { noremap=true, silent=true })
buf_set_keymap('n', '<leader>gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', { noremap=true, silent=true })
buf_set_keymap('n', '<leader>dl', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', { noremap=true, silent=true })
buf_set_keymap('n', '<leader>dn', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', { noremap=true, silent=true })
buf_set_keymap('n', '<leader>dp', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', { noremap=true, silent=true })
buf_set_keymap('n', '<leader>de', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', { noremap=true, silent=true })
buf_set_keymap('n', '<leader>gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', { noremap=true, silent=true })
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', { noremap=true, silent=true })
buf_set_keymap("n", "<leader>ff", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', '<leader>dec', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
--buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
--buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
--buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
--buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
end
-- Go
lspconfig.gopls.setup{
on_attach = custom_attach,
cmd = {"gopls", "serve"},
settings = {
gopls = {
analyses = {
unusedparams = true,
},
gofumpt = true,
staticcheck = true,
},
init_options = {
usePlaceholders = true,
completeUnimported = true,
hoverKind = "FullDocumentation",
},
},
}
-- Golangci-lint language server
-- requires golangci-lint and golangci-lint-langserver
lspconfig.golangci_lint_ls.setup{}
-- Jsonnet
lspconfig.jsonnet_ls.setup{
on_attach = custom_attach,
}
-- Terraform
lspconfig.terraformls.setup{
on_attach = custom_attach,
cmd = {"terraform-ls", "serve"},
filetypes = {"terraform", "hcl", "tf"},
root_dir = lspconfig.util.root_pattern{".terraform", ".git", "main.tf"},
}
-- Python
lspconfig.pylsp.setup{
on_attach = custom_attach,
cmd = { "pylsp" },
filetypes = { "python" },
}
-- Lua
local sumneko_root_path = vim.fn.expand('$HOME') .. "/Git/github.com/sumneko/lua-language-server"
local sumneko_binary = sumneko_root_path .. "/bin/Linux/lua-language-server"
lspconfig.sumneko_lua.setup {
on_attach = custom_attach,
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
-- Setup your lua path
path = vim.split(package.path, ';')
},
diagnostics = {
-- Get the language server to recognize the vim and awesome globals
globals = {'vim', 'awesome'}
},
workspace = {
-- 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
enable = false,
},
}
}
}

View file

@ -9,16 +9,12 @@ treesitter.setup {
"bash",
"go",
"gomod",
"gosum",
"gotmpl",
"hcl",
"json",
"lua",
"make",
"python",
"yaml",
"terraform",
"vimdoc",
},
highlight = {

View file

@ -0,0 +1,74 @@
local function t(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
function _G.smart_tab()
return vim.fn.pumvisible() == 1 and t'<C-n>' or t'<TAB>'
end
function _G.reverse_smart_tab()
return vim.fn.pumvisible() == 1 and t'<C-p>' or t'<TAB>'
end
local keybind = vim.api.nvim_set_keymap
-- Disable arrow key navigation
keybind("n", "<Up>", "<Nop>", { noremap = true })
keybind("n", "<Down>", "<Nop>", { noremap = true })
keybind("n", "<Left>", "<Nop>", { noremap = true })
keybind("n", "<Right>", "<Nop>", { noremap = true })
keybind("i", "<Up>", "<Nop>", { noremap = true })
keybind("i", "<Down>", "<Nop>", { noremap = true })
keybind("i", "<Left>", "<Nop>", { noremap = true })
keybind("i", "<Right>", "<Nop>", { noremap = true })
keybind("v", "<Up>", "<Nop>", { noremap = true })
keybind("v", "<Down>", "<Nop>", { noremap = true })
keybind("v", "<Left>", "<Nop>", { noremap = true })
keybind("v", "<Right>", "<Nop>", { noremap = true })
-- Copy and paste to/from the OS clipboard
keybind("n", "<leader>y", "\"+y", { noremap = true})
keybind("n", "<leader>yy", "\"+yy", { noremap = true})
keybind("v", "<leader>y", "\"+y", { noremap = true})
keybind("n", "<leader>p", "\"+p", { noremap = true})
keybind("n", "<leader>P", "\"+P", { noremap = true})
keybind("v", "<leader>p", "\"+p", { noremap = true})
keybind("v", "<leader>P", "\"+P\"`\"`", { noremap = true})
-- copy the whole file to the OS clipboard
keybind("n", "<leader>c", ":%y+<CR>", { noremap = true})
-- Control buffer splits
keybind("n", "<C-l>", ":vert resize +5<CR>", { noremap = true })
keybind("n", "<C-h>", ":vert resize -5<CR>", { noremap = true })
keybind("n", "<C-k>", ":resize -5<CR>", { noremap = true })
keybind("n", "<C-j>", ":resize +5<CR>", { noremap = true })
-- Add matching curly brace
keybind("i", "\\{", "{<cr>}<ESC>O", { noremap = true })
keybind("i", ">{", "{}<ESC>a", { noremap = true })
keybind("i", "<{", "{}<ESC>i", { noremap = true })
-- Add matching parenthesis
keybind("i", "\\(", "(<cr>)<ESC>O", { noremap = true })
keybind("i", ">(", "()<ESC>a", { noremap = true })
keybind("i", "<(", "()<ESC>i", { noremap = true })
-- Add matching square brace
keybind("i", "\\[", "[<cr>]<ESC>O", { noremap = true })
keybind("i", ">[", "[]<ESC>a", { noremap = true })
keybind("i", "<[", "[]<ESC>i", { noremap = true })
-- Use the TAB key to cycle through the autocompletion popup menu
keybind("i", "<TAB>", "v:lua.smart_tab()", { expr = true, noremap = true })
keybind("i", "<S-TAB>", "v:lua.reverse_smart_tab()", { expr = true, noremap = true })
-- Use CTRL+Space to open the autocompletion popup menu
keybind("i", "<C-SPACE>", "<C-x><C-o>", { noremap = true })
-- Bufferline
keybind("n", "<leader>bn", ":BufferLineCycleNext<CR>", { noremap = true})
keybind("n", "<leader>bp", ":BufferLineCyclePrev<CR>", { noremap = true})

74
neovim/lua/options.lua Normal file
View file

@ -0,0 +1,74 @@
local set = vim.opt
local g = vim.g
local cmd = vim.cmd
-- TODO: Use vim.fn.stdpath("state") when it is GA.
local state_directory = vim.env.XDG_STATE_HOME .. "/nvim"
g.mapleader = ","
-- State files
set.backup = true
set.writebackup = true
set.backupdir = state_directory .. "/backup"
set.swapfile = true
set.directory = state_directory .. "/swap"
set.undofile = true
set.undodir = state_directory .. "/undo"
set.viewdir = state_directory .. "/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"
-- The Statusline
local statusline = require("statusline")
set.statusline = statusline.output()
set.laststatus = 3

49
neovim/lua/plugins.lua Normal file
View file

@ -0,0 +1,49 @@
return require("packer").startup(function(use)
-- Packer can manage itself
use {
"wbthomason/packer.nvim",
commit = "4dedd3b08f8c6e3f84afbce0c23b66320cd2a8f2", -- 2022-03-23
}
use {
"folke/tokyonight.nvim",
commit = "8223c970677e4d88c9b6b6d81bda23daf11062bb", -- 2021-12-31
}
use {
"neovim/nvim-lspconfig",
commit = "629f45d7ea1b3407e7c9639a7c4c992b1cdfefee", -- 2022-05-10
config = require("config.lsp"),
}
use {
"nvim-treesitter/nvim-treesitter",
commit = "c004155676180a683ad424fe57294923cdf702ee", -- 2022-05-17
config = require("config.treesitter"),
run = ":TSUpdate",
}
use {
"kyazdani42/nvim-web-devicons",
commit = "cde67b5d5427daeecfd7c77cf02ded23a26980bb", -- 2022-05-14
}
use {
"akinsho/bufferline.nvim",
tag = "v2.1.0",
requires = "kyazdani42/nvim-web-devicons",
config = require("config.bufferline"),
}
use {
"mfussenegger/nvim-dap",
commit = "a9c49a5f9dc21e4e9359c2b7fe30ed3a2f65cd9a", -- 2022-05-14
}
use {
"leoluz/nvim-dap-go",
commit = "fca8bf90bf017e8ecb3a3fb8c3a3c05b60d1406d", -- 2022.02.07
config = require("config.dap-go"),
}
end)

View file

@ -45,7 +45,7 @@ local theme = require("statusline.themes.tokyonight")
local ns = vim.api.nvim_create_namespace("statusline")
function M.output()
vim.api.nvim_set_hl_ns(ns)
vim.api.nvim__set_hl_ns(ns)
for name, settings in pairs(theme.theme) do
vim.api.nvim_set_hl(ns, name, settings)

View file

@ -1,7 +0,0 @@
local setlocal = vim.opt_local
-- Tabs and spaces
setlocal.expandtab = false
setlocal.tabstop = 8
setlocal.shiftwidth = 8
setlocal.softtabstop = 8

View file

@ -1,5 +0,0 @@
require("options")
require("plugins")
require("keymappings")
require("autocommands")
require("ftdetect")

View file

@ -1,6 +0,0 @@
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = '*.go',
callback = function()
vim.lsp.buf.code_action({ context = { only = { 'source.organizeImports' } }, apply = true })
end
})

View file

@ -1,4 +0,0 @@
vim.api.nvim_create_autocmd(
{ "BufNewFile", "BufRead"},
{ pattern = {"*.gotmpl"}, command = "set ft=gotmpl" }
)

View file

@ -1,2 +0,0 @@
require("ftdetect.jsonnet")
require("ftdetect.gotmpl")

View file

@ -1,77 +0,0 @@
local function t(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
function _G.smart_tab()
return vim.fn.pumvisible() == 1 and t'<C-n>' or t'<TAB>'
end
function _G.reverse_smart_tab()
return vim.fn.pumvisible() == 1 and t'<C-p>' or t'<TAB>'
end
-- Disable arrow key navigation
vim.keymap.set("n", "<Up>", "<Nop>", { noremap = true })
vim.keymap.set("n", "<Down>", "<Nop>", { noremap = true })
vim.keymap.set("n", "<Left>", "<Nop>", { noremap = true })
vim.keymap.set("n", "<Right>", "<Nop>", { noremap = true })
vim.keymap.set("i", "<Up>", "<Nop>", { noremap = true })
vim.keymap.set("i", "<Down>", "<Nop>", { noremap = true })
vim.keymap.set("i", "<Left>", "<Nop>", { noremap = true })
vim.keymap.set("i", "<Right>", "<Nop>", { noremap = true })
vim.keymap.set("v", "<Up>", "<Nop>", { noremap = true })
vim.keymap.set("v", "<Down>", "<Nop>", { noremap = true })
vim.keymap.set("v", "<Left>", "<Nop>", { noremap = true })
vim.keymap.set("v", "<Right>", "<Nop>", { noremap = true })
-- Copy and paste to/from the OS clipboard
vim.keymap.set("n", "<leader>y", "\"+y", { noremap = true})
vim.keymap.set("n", "<leader>yy", "\"+yy", { noremap = true})
vim.keymap.set("v", "<leader>y", "\"+y", { noremap = true})
vim.keymap.set("n", "<leader>p", "\"+p", { noremap = true})
vim.keymap.set("n", "<leader>P", "\"+P", { noremap = true})
vim.keymap.set("v", "<leader>p", "\"+p", { noremap = true})
vim.keymap.set("v", "<leader>P", "\"+P\"`\"`", { noremap = true})
-- copy the whole file to the OS clipboard
vim.keymap.set("n", "<leader>c", ":%y+<CR>", { noremap = true})
-- Control buffer splits
vim.keymap.set("n", "<C-l>", ":vert resize +5<CR>", { noremap = true })
vim.keymap.set("n", "<C-h>", ":vert resize -5<CR>", { noremap = true })
vim.keymap.set("n", "<C-k>", ":resize -5<CR>", { noremap = true })
vim.keymap.set("n", "<C-j>", ":resize +5<CR>", { noremap = true })
-- Add matching curly brace
vim.keymap.set("i", "\\{", "{<cr>}<ESC>O", { noremap = true })
vim.keymap.set("i", ">{", "{}<ESC>a", { noremap = true })
vim.keymap.set("i", "<{", "{}<ESC>i", { noremap = true })
-- Add matching parenthesis
vim.keymap.set("i", "\\(", "(<cr>)<ESC>O", { noremap = true })
vim.keymap.set("i", ">(", "()<ESC>a", { noremap = true })
vim.keymap.set("i", "<(", "()<ESC>i", { noremap = true })
-- Add matching square brace
vim.keymap.set("i", "\\[", "[<cr>]<ESC>O", { noremap = true })
vim.keymap.set("i", ">[", "[]<ESC>a", { noremap = true })
vim.keymap.set("i", "<[", "[]<ESC>i", { noremap = true })
-- Use the TAB key to cycle through the autocompletion popup menu
vim.keymap.set("i", "<TAB>", "v:lua.smart_tab()", { expr = true, noremap = true })
vim.keymap.set("i", "<S-TAB>", "v:lua.reverse_smart_tab()", { expr = true, noremap = true })
-- Use CTRL+Space to open the autocompletion popup menu
vim.keymap.set("i", "<C-SPACE>", "<C-x><C-o>", { noremap = true })
-- Bufferline
vim.keymap.set("n", "<leader>bn", ":BufferLineCycleNext<CR>", { noremap = true})
vim.keymap.set("n", "<leader>bp", ":BufferLineCyclePrev<CR>", { noremap = true})
-- LF
vim.keymap.set("n", "<leader>ll", ":LfEdit<CR>", { noremap = true})
vim.keymap.set("n", "<leader>ls", ":LfSplit<CR>", { noremap = true})
vim.keymap.set("n", "<leader>lv", ":LfVsplit<CR>", { noremap = true})

View file

@ -1,78 +0,0 @@
local set = vim.opt
local g = vim.g
local cmd = vim.cmd
local data_directory = vim.fn.stdpath("data")
local state_directory = vim.fn.stdpath("state")
g.mapleader = ","
-- State files
set.backup = true
set.writebackup = true
set.backupdir = state_directory .. "/backup"
set.swapfile = true
set.directory = state_directory .. "/swap"
set.undofile = true
set.undodir = state_directory .. "/undo"
set.viewdir = state_directory .. "/view"
set.spellfile = data_directory .. "/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 white spaces 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"
-- UI and UX
set.number = true -- enable line numbers
set.relativenumber = true -- enable relative 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
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 mode lines.
set.cursorline = true -- highlight the line that the cursor is on
set.smartindent = true -- smart auto-identing
set.mouse = "" -- completely disable mouse support :<
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"
-- Spelling
set.spell = true
set.spelllang = "en_gb"
-- Disable unwanted providers
g.loaded_ruby_provider = 0
g.loaded_perl_provider = 0
g.loaded_python3_provider = 0
g.loaded_node_provider = 0
-- The Statusline
local statusline = require("statusline")
set.statusline = statusline.output()
set.laststatus = 3

View file

@ -1,23 +0,0 @@
local ok, lint = pcall(require, "lint")
if not ok then
return
end
lint.linters_by_ft = {
go = {'golangcilint'},
sh = {'shellcheck'},
python = {'pylint'},
}
vim.api.nvim_create_autocmd('BufWritePost', {
callback = function()
local ok, lint = pcall(require, "lint")
if not ok then
return
end
lint.try_lint()
end
})

View file

@ -1,139 +0,0 @@
local ok, lspconfig = pcall(require, "lspconfig")
if not ok then
return
end
local ok, util = pcall(require, "lspconfig/util")
if not ok then
return
end
local log_directory = vim.env.LOG_HOME
if log_directory == nil then
log_directory = "/tmp"
end
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
-- See `:help vim.diagnostic.*` for documentation on any of the diagnostics functions
local opts = { noremap=true, silent=true, buffer=ev.buf }
vim.keymap.set('n', '<leader>h', vim.lsp.buf.hover, opts)
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', '<leader>gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<leader>gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<leader>dl', vim.diagnostic.setloclist, opts)
vim.keymap.set('n', '<leader>dn', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<leader>dp', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', '<leader>gt', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set("n", '<leader>ff', function() vim.lsp.buf.format{ async = true } end, opts)
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', '<leader>dec', vim.lsp.buf.declaration, opts)
if vim.lsp.inlay_hint then
vim.keymap.set('n', '<leader>ih', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, opts)
end
--vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
--vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
--vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
--vim.keymap.set('n', '<space>wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end', opts)
end,
})
local lsp_flags = {
debounce_text_changes = 150,
}
-- Go
lspconfig.gopls.setup{
cmd = {"gopls", "serve", "-logfile="..log_directory.."/gopls.log"},
filetypes = {"go", "gomod"},
root_dir = util.root_pattern("go.work", "go.mod", ".git"),
settings = {
gopls = {
analyses = {
unusedparams = true,
useany = true,
},
env = {
GOFLAGS = "-tags=mage",
},
gofumpt = true,
hints = {
parameterNames = true,
constantValues = true,
compositeLiteralFields = true,
assignVariableTypes = true,
},
staticcheck = true,
vulncheck = "Imports",
usePlaceholders = true,
},
},
flags = lsp_flags,
}
-- Jsonnet
lspconfig.jsonnet_ls.setup{
cmd = {"jsonnet-language-server", "--lint"},
flags = lsp_flags,
}
-- Terraform
lspconfig.terraformls.setup{
cmd = {"terraform-ls", "serve", "-log-file="..log_directory.."/terraformls.log"},
filetypes = {"terraform", "hcl", "tf"},
root_dir = lspconfig.util.root_pattern{".terraform", ".git", "main.tf"},
flags = lsp_flags,
}
-- Python
lspconfig.pylsp.setup{
cmd = { "pylsp" },
filetypes = { "python" },
flags = lsp_flags,
}
-- Lua
lspconfig.lua_ls.setup {
on_init = function(client)
local path = client.workspace_folders[1].name
if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT'
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
}
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
}
}
})
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end
return true
end,
flags = lsp_flags,
}

View file

@ -1,13 +0,0 @@
local ok, peek = pcall(require, "peek")
if not ok then
return
end
peek.setup{
theme = "dark",
app = "webview",
}
vim.api.nvim_create_user_command("PeekOpen", peek.open, {})
vim.api.nvim_create_user_command("PeekClose", peek.close, {})

View file

@ -1,16 +0,0 @@
local ok, tokyonight = pcall(require, "tokyonight")
if not ok then
return
end
tokyonight.setup {
style = "night",
sidebars = {"terminal"},
dim_inactive = true,
on_highlights = function(hl, c)
hl.NormalFloat = {
bg = "#394b70",
}
end,
}

View file

@ -1,35 +0,0 @@
local ok, tui_nvim = pcall(require, "tui-nvim")
if not ok then
return
end
tui_nvim.setup{}
local lf = function(method)
local lf_cmd = vim.env.GOBIN .. "/lf"
local tempfile = vim.fn.stdpath("cache") .. "/tui-nvim"
tui_nvim:new {
cmd = lf_cmd .. " -selection-path " .. tempfile .. " " .. vim.env.PWD,
temp = tempfile,
method = method,
}
end
local LfEdit = function()
lf("edit")
end
local LfSplit = function()
lf("split")
end
local LfVsplit = function()
lf("vsplit")
end
vim.api.nvim_create_user_command( 'LfEdit', LfEdit, {} )
vim.api.nvim_create_user_command( 'LfSplit', LfSplit, {} )
vim.api.nvim_create_user_command( 'LfVsplit', LfVsplit, {} )

View file

@ -1,89 +0,0 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
local set = vim.opt
local cmd = vim.cmd
vim.opt.runtimepath:prepend(lazypath)
local plugins = {
{
-- Source: https://github.com/folke/tokyonight.nvim
"folke/tokyonight.nvim",
tag = "v3.0.1", -- 2024-01-21
priority = 1000,
config = function()
require("plugins.config.tokyonight")
set.termguicolors = true
set.background = "dark"
cmd "colorscheme tokyonight-night"
end,
},
{
-- Source: https://github.com/neovim/nvim-lspconfig
"neovim/nvim-lspconfig",
tag = "v0.1.8", -- 2024-05-21
config = function()
require("plugins.config.lsp")
end,
},
{
-- Source: https://github.com/nvim-treesitter/nvim-treesitter
"nvim-treesitter/nvim-treesitter",
commit = "f0e3b5c5fe38d0012c63368db90017fef87c85a2", -- 2024-06-29
config = function()
require("plugins.config.treesitter")
end,
build = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
},
{
-- Source: https://github.com/nvim-tree/nvim-web-devicons
"nvim-tree/nvim-web-devicons",
commit = "c0cfc1738361b5da1cd0a962dd6f774cc444f856", -- 2024-06-09
},
{
-- Source: https://github.com/akinsho/bufferline.nvim
"akinsho/bufferline.nvim",
tag = "v4.6.1", -- 2024.05.21
dependencies = {
"nvim-tree/nvim-web-devicons",
},
config = function()
require("plugins.config.bufferline")
end,
},
{
-- Source: https://github.com/is0n/tui-nvim
"is0n/tui-nvim",
commit = "2eeff3ac921f53bdb837d23d6e4501d97807994c", -- 2022.05.07
config = function()
require("plugins.config.tui_nvim")
end,
},
{
-- Source: https://github.com/mfussenegger/nvim-lint
"mfussenegger/nvim-lint",
commit = "efc6fc83f0772283e064c53a8f9fb5645bde0bc0", -- 2024.06.26
config = function()
require("plugins.config.lint")
end,
},
{
-- Source: https://github.com/toppair/peek.nvim
"toppair/peek.nvim",
commit = "5820d937d5414baea5f586dc2a3d912a74636e5b", -- 2024.04.09
build = "deno task --quiet build:fast",
config = function()
require("plugins.config.peek")
end,
},
}
require("lazy").setup(plugins, {
lockfile = vim.fn.stdpath("state") .. "/lazy/lock.json",
performance = {
cache = {
enabled = true,
}
}
})