Initial commit, added nvim

This commit is contained in:
Louis Hollingworth 2024-05-22 17:11:29 +01:00
commit f5f7885578
Signed by: lucxjo
GPG key ID: A11415CB3DC7809B
13 changed files with 544 additions and 0 deletions

2
README.md Normal file
View file

@ -0,0 +1,2 @@
# Dots
My dot files, to be managed with GNU Stow.

View file

@ -0,0 +1,173 @@
local keymap = vim.keymap.set
require('mason').setup({
ui = {
icons = {
server = "",
lsp = "",
linter = "",
formatter = "",
package_installed = "",
package_pending = "",
package_uninstalled = ""
},
},
})
require("mason-lspconfig").setup({
automatic_installation = true,
})
local lsp = require('lspconfig')
local cmp = require('cmp')
local cmp_select = {behavior = cmp.SelectBehavior.Select}
local opts = { noremap=true, silent=true }
--keymap('i', '<C-Space>', vim.diagnostic.open_float, opts)
--keymap('i', '<C-p>', vim.diagnostic.goto_prev, opts)
--keymap('i', '<C-n>', vim.diagnostic.goto_next, opts)
--keymap('i', '<C-Space>', cmp.mapping.complete(), opts)
--keymap('i', '<CR>', vim.diagnostic.setloclist, opts)
keymap('n', '<C-Space>', vim.diagnostic.open_float, opts)
keymap('n', '<C-p>', vim.diagnostic.goto_prev, opts)
keymap('n', '<C-n>', vim.diagnostic.goto_next, opts)
--keymap('i', '<C-Space>', cmp.mapping.complete(), opts)
keymap('n', '<CR>', vim.diagnostic.setloclist, opts)
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-Space>'] = cmp.mapping.complete(cmp_select),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
},
})
vim.diagnostic.config({
virtual_text = true,
})
local on_attach = function(client, bufnr)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
-- Mappings.
local opts = { noremap = true, silent = true, buffer = bufnr}
-- See `:help vim.lsp.*` for documentation on any of the below functions
vim.keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
vim.keymap.set("n", "gr", "<cmd>Telescope lsp_references<CR>", opts)
vim.keymap.set("n", "<C-j>", "<cmd>Telescope lsp_document_symbols<CR>", opts)
vim.keymap.set("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
vim.keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts)
vim.keymap.set("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
vim.keymap.set("n", "<leader>D", "<cmd>Telescope lsp_type_definitions<CR>", opts)
vim.keymap.set("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
vim.keymap.set("n", "<leader>ca", "<cmd>Telescope lsp_code_actions<CR>", opts)
vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, {buffer=0})
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, {buffer=0})
vim.keymap.set("n", "<leader>dj", vim.diagnostic.goto_next, {buffer=0})
vim.keymap.set("n", "<leader>dk", vim.diagnostic.goto_prev, {buffer=0})
vim.keymap.set("n", "<leader>dl", "<cmd>Telescope diagnostics<cr>", {buffer=0})
vim.keymap.set("n", "<leader>r", vim.lsp.buf.rename, {buffer=0})
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, {buffer=0})
-- Set autocommands conditional on server_capabilities
if client.server_capabilities.document_highlight then
vim.cmd([[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]])
end
end
lsp.gopls.setup({
on_attach = on_attach,
flags = lsp_flags,
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
},
},
})
lsp['lua_ls'].setup{
on_attach = on_attach,
flags = lsp_flags,
}
lsp['rust_analyzer'].setup{
on_attach = on_attach,
flags = lsp_flags,
cmd = {
"rustup", "run", "stable", "rust-analyzer",
},
settings = {
["rust-analyzer"] = {
procMacro = {
ignored = {
leptos_macro = {
"island",
"server",
},
},
},
},
},
}
lsp.clangd.setup{
on_attach = on_attach,
flags = lsp_flags,
}
lsp.emmet_ls.setup({
-- on_attach = on_attach,
capabilities = capabilities,
filetypes = { "css", "eruby", "html", "javascript", "javascriptreact", "less", "sass", "scss", "svelte", "pug", "typescriptreact", "vue" },
init_options = {
html = {
options = {
-- For possible options, see: https://github.com/emmetio/emmet/blob/master/src/config.ts#L79-L267
["bem.enabled"] = true,
},
},
}
})
lsp.tsserver.setup{
on_attach = on_attach,
flags = lsp_flags,
}
lsp.zls.setup{
capabilities = capabilities,
flags = lsp_flags,
on_attach = on_attach,
}
lsp.texlab.setup {}

View file

@ -0,0 +1 @@
require("lucxjo")

View file

@ -0,0 +1,39 @@
{
"LuaSnip": { "branch": "master", "commit": "b152822e1a4bafb6bdf11a16cc26525cbd95ee00" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"editorconfig-vim": { "branch": "master", "commit": "8b7da79e9daee7a3f3a8d4fe29886b9756305aff" },
"formatter.nvim": { "branch": "master", "commit": "ad246d34ce7a32f752071ed81b09b94e6b127fad" },
"friendly-snippets": { "branch": "main", "commit": "d5f74ce4dfdd82848f3f4eac65fe6e29ac5df4c2" },
"gitsigns.nvim": { "branch": "main", "commit": "790355f00af1fc2c330ea1b2b7f68d65f19b57c9" },
"glow.nvim": { "branch": "main", "commit": "238070a686c1da3bccccf1079700eb4b5e19aea4" },
"headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" },
"lazy.nvim": { "branch": "main", "commit": "3f13f080434ac942b150679223d54f5ca91e0d52" },
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
"lspsaga.nvim": { "branch": "main", "commit": "052234296f13e2705d5d290c7bd5a36d3dd81fde" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "273fdde8ac5e51f3a223ba70980e52bbc09d9f6f" },
"mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" },
"noice.nvim": { "branch": "main", "commit": "0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12" },
"nord.nvim": { "branch": "master", "commit": "80c1e5321505aeb22b7a9f23eb82f1e193c12470" },
"nui.nvim": { "branch": "main", "commit": "cbd2668414331c10039278f558630ed19b93e69b" },
"nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" },
"nvim-dap": { "branch": "master", "commit": "6ae8a14828b0f3bff1721a35a1dfd604b6a933bb" },
"nvim-dap-ui": { "branch": "master", "commit": "5934302d63d1ede12c0b22b6f23518bb183fc972" },
"nvim-lint": { "branch": "master", "commit": "861a04313501563bb1b11f125ae9b7237a517b9b" },
"nvim-lspconfig": { "branch": "master", "commit": "aa5f4f4ee10b2688fb37fa46215672441d5cd5d9" },
"nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" },
"nvim-treesitter": { "branch": "master", "commit": "1a4274c9e1226fb4c2009f4c0c3521b1931b0c5c" },
"nvim-web-devicons": { "branch": "master", "commit": "794bba734ec95eaff9bb82fbd112473be2087283" },
"oil.nvim": { "branch": "master", "commit": "f3a31eba24587bc038592103d8f7e64648292115" },
"plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
"telescope.nvim": { "branch": "master", "commit": "35f94f0ef32d70e3664a703cefbe71bd1456d899" },
"todo-comments.nvim": { "branch": "main", "commit": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d" },
"undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" },
"vim-grammarous": { "branch": "master", "commit": "db46357465ce587d5325e816235b5e92415f8c05" },
"vim-wakatime": { "branch": "master", "commit": "3cb40867cb5a3120f9bef76eff88edc7f1dc1a23" },
"vimtex": { "branch": "master", "commit": "a80934749c69cc6875b3c9b13ef59573a4824fb2" }
}

View file

@ -0,0 +1,43 @@
require("lucxjo.keys")
require("lucxjo.lazy")
require("lucxjo.opts")
local augroup = vim.api.nvim_create_augroup
local lucxjo_group = augroup('lucxjo', {})
local aucmd = vim.api.nvim_create_autocmd
local yank_group = augroup('HlYank', {})
aucmd('TextYankPost', {
group = yank_group,
pattern = '*',
callback = function()
vim.highlight.on_yank({
higroup = 'IncSearch',
timeout = 40,
})
end,
})
aucmd({"BufWritePre"}, {
group = lucxjo_group,
pattern = "*",
command = [[%s/\s\+$//e]],
})
aucmd('LspAttach', {
group = lucxjo,
callback = function(e)
local opts = { buffer = e.buf }
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
end
})

View file

@ -0,0 +1,13 @@
vim.g.mapleader = " "
local map = vim.api.nvim_set_keymap
map("n", "<leader>p", ":Glow<cr>", {})
map("n", "<leader>ch", ":nohl<cr>", { silent = true })
-- File management
map("n", "<leader>s", ":w<cr>", { silent = true})
map("n", "<leader>q", ":q<cr>", {})
map("n", "<leader>Q", ":q!<cr>", {})
map("n", "<leader>S", ":wq<cr>", {})
map("n", "<leader>fp", ":Oil<cr>", {})

View file

@ -0,0 +1,14 @@
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)
require("lazy").setup("lucxjo.plugins")

View file

@ -0,0 +1,39 @@
local opt = vim.opt
-- Context
opt.colorcolumn = "80"
opt.number = true
opt.relativenumber = true
opt.scrolloff = 4
opt.signcolumn = "yes"
-- Filetypes
opt.encoding = "utf8"
opt.fileencoding = "utf8"
-- Theme
opt.syntax = "ON"
opt.termguicolors = true
-- Search
opt.ignorecase = true
opt.smartcase = true
opt.incsearch = true
opt.hlsearch = true
-- Whitespace
opt.expandtab = true
opt.shiftwidth = 4
opt.softtabstop = 4
opt.tabstop = 4
opt.smartindent = true
-- Undo
opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
opt.undofile = true
-- Misc
opt.backspace = "indent,eol,start"
opt.clipboard:append("unnamedplus")
opt.iskeyword:append("-")
vim.cmd[[colorscheme nord]]

View file

@ -0,0 +1,87 @@
return {
{
'shaunsingh/nord.nvim',
lazy = false,
priority = 1000,
dependencies = "lukas-reineke/headlines.nvim",
config = function()
require("headlines").setup({
markdown = {
headline_highlights = {
"Headline1",
"Headline2",
"Headline3",
"Headline4",
"Headline5",
"Headline6",
},
codeblock_highlight = "CodeBlock",
dash_highlight = "Dash",
quote_highlight = "Quote",
},
})
end,
},
{
"lukas-reineke/headlines.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
config = true, -- or `opts = {}`
},
"editorconfig/editorconfig-vim",
{
"ellisonleao/glow.nvim",
config = function() require("glow").setup() end,
},
{
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function() require("lualine").setup{
options = {
theme = "nord",
},
} end,
},
"wakatime/vim-wakatime",
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {},
},
"nvim-tree/nvim-web-devicons",
"mbbill/undotree",
{
"lewis6991/gitsigns.nvim",
config = function ()
require("gitsigns").setup()
end,
},
{
"folke/noice.nvim",
event = "VeryLazy",
opts = {
-- add any options here
},
dependencies = {
-- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
"MunifTanjim/nui.nvim",
-- OPTIONAL:
-- `nvim-notify` is only needed, if you want to use the notification view.
-- If not available, we use `mini` as the fallback
"rcarriga/nvim-notify",
}
},
{
'stevearc/oil.nvim',
opts = {
default_file_explorer = true,
constrain_cursor = "name",
view_options = {
-- Show files and directories that start with "."
show_hidden = true,
}
},
-- Optional dependencies
dependencies = { "nvim-tree/nvim-web-devicons" },
},
'rhysd/vim-grammarous',
}

View file

@ -0,0 +1,63 @@
return {
-- Autocomplete
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
-- Snippets
{
"L3MON4D3/LuaSnip",
build = "make install_jsregexp",
},
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
-- Manage
{
"williamboman/mason.nvim",
config = function() require("mason").setup() end,
},
{
"williamboman/mason-lspconfig.nvim",
config = function() require("mason-lspconfig").setup() end,
},
-- Configure
"neovim/nvim-lspconfig",
"hrsh7th/cmp-nvim-lsp",
"glepnir/lspsaga.nvim",
"onsails/lspkind.nvim",
-- Lint
{
"mfussenegger/nvim-lint",
config = function()
require("lint").linters_by_ft = {
go = {'golangclient'},
lua = {'luacheck'},
sh = {'shellcheck'},
c = {'cpplint'}
}
end,
},
-- Format
{
"mhartington/formatter.nvim",
config = function()
require("formatter").setup()
end,
},
-- DAP
{
"rcarriga/nvim-dap-ui",
dependencies = {"mfussenegger/nvim-dap"}
},
{
'lervag/vimtex',
config = function()
vim.g.vimtex_view_method = "zathura"
end,
}
}

View file

@ -0,0 +1,20 @@
return {
{
'nvim-telescope/telescope.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-fzf-native.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, {})
end,
},
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build'
},
}

View file

@ -0,0 +1,12 @@
return {
"nvim-treesitter/nvim-treesitter",
config = function()
require('nvim-treesitter.install').update({ with_sync = true })
require('nvim-treesitter.configs').setup({
highlight = {
enable = true,
diable = { "latex" },
}
})
end,
}

38
setup.sh Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
# what directories should be installable by all users including the root user
base=(
)
# folders that should, or only need to be installed for a local user
useronly=(
nvim
)
# run the stow command for the passed in directory ($2) in location $1
stowit() {
usr=$1
app=$2
# -v verbose
# -R recursive
# -t target
stow -v -R -t ${usr} ${app}
}
echo ""
echo "Stowing apps for user: ${whoami}"
# install apps available to local users and root
for app in ${base[@]}; do
stowit "${HOME}" $app
done
# install only user space folders
for app in ${useronly[@]}; do
if [[! "$(whoami)" = *"root"*]]; then
stowit "${HOME}" $app
fi
done
echo ""
echo "##### ALL DONE"