neovim setup

This commit is contained in:
2024-01-28 16:36:57 +01:00
commit 897151daf9
48 changed files with 1191 additions and 0 deletions

14
.luacheckrc Normal file
View File

@@ -0,0 +1,14 @@
---@diagnostic disable: lowercase-global
ignore = {
"111", -- setting non-standard global variable
"212/_.*", -- unused argument, for vars with "_" prefix
"214", -- used variable with unused hint ("_" prefix)
"121", -- setting read-only global variable 'vim'
"122", -- setting read-only field of global variable 'vim'
}
-- Global objects defined by the C code
read_globals = {
"vim",
}

8
.luarc.json Normal file
View File

@@ -0,0 +1,8 @@
{
"diagnostics.globals": [
"vim"
],
"diagnostics.disable": [
"different-requires"
]
}

12
README.md Normal file
View File

@@ -0,0 +1,12 @@
# nvim installatie uitbreidingen
### Links
[Video](https://youtu.be/ZjMzBd1Dqz8) die als leidraad werd gebruikt voor mijn installatie.
De [github](https://github.com/radleylewis/nvim) site die er bij hoort.
### Inleiding
Zoekende naar een bevredigende oplossing om python te programmeren in Neovim heb ik bovenstaande video als leidraad genomen om mijn Neovim als IDE in te stellen.
In principe kwam het er op neer dat ik de video heb bekeken en de instellingen van hem heb gekopieerd.

1
init.lua Normal file
View File

@@ -0,0 +1 @@
require('config')

47
lazy-lock.json Normal file
View File

@@ -0,0 +1,47 @@
{
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"copilot-cmp": { "branch": "master", "commit": "72fbaa03695779f8349be3ac54fa8bd77eed3ee3" },
"copilot.lua": { "branch": "master", "commit": "b03617a6dc4bc88b65ab5deac1631da9a9c2dcaf" },
"efmls-configs-nvim": { "branch": "main", "commit": "5372981bc8785facefb51cd50cb0888d1129a291" },
"gitsigns.nvim": { "branch": "main", "commit": "300a306da9973e81c2c06460f71fd7a079df1f36" },
"hardtime.nvim": { "branch": "main", "commit": "4ba3be553fa0b713c7b817f6d201b07d282accf3" },
"indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" },
"lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" },
"leap.nvim": { "branch": "main", "commit": "9f7cf0a87ca2c3f47df37ef6787d34a65604d248" },
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
"lspsaga.nvim": { "branch": "main", "commit": "2198c07124bef27ef81335be511c8abfd75db933" },
"lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "3ba1b92b771f33256b4969d696b82c8ae7075364" },
"mason.nvim": { "branch": "main", "commit": "9c9416817c9f4e6f333c749327a1ed5355cfab61" },
"neoconf.nvim": { "branch": "main", "commit": "cfc29315288515849aa54c05828d49f01f033b66" },
"neodev.nvim": { "branch": "main", "commit": "5bbbeda6a9c672f314c95ca47a8b495cf6de17f9" },
"neorg": { "branch": "main", "commit": "28cbafbc0cde316d8e2618ff26377200225e9393" },
"nightfox.nvim": { "branch": "main", "commit": "a4bc2bd3d7ff1770ae104068458d3b0b8f8ec00d" },
"noice.nvim": { "branch": "main", "commit": "92433164e2f7118d4122c7674c3834d9511722ba" },
"nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" },
"nvim-autopairs": { "branch": "master", "commit": "096d0baecc34f6c5d8a6dd25851e9d5ad338209b" },
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
"nvim-dap": { "branch": "master", "commit": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5" },
"nvim-dap-python": { "branch": "master", "commit": "091e4ae00a12085f9ed4200a3cd04af7179b8a23" },
"nvim-dap-ui": { "branch": "master", "commit": "d845ebd798ad1cf30aa4abd4c4eff795cdcfdd4f" },
"nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" },
"nvim-tree.lua": { "branch": "master", "commit": "7bdb220d0fe604a77361e92cdbc7af1b8a412126" },
"nvim-treesitter": { "branch": "master", "commit": "cd4e0909948eb33d3959e133c16f837e4db122c6" },
"nvim-ts-autotag": { "branch": "main", "commit": "8515e48a277a2f4947d91004d9aa92c29fdc5e18" },
"nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" },
"plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" },
"rust-tools.nvim": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" },
"tailwindcss-colorizer-cmp.nvim": { "branch": "main", "commit": "bc25c56083939f274edcfe395c6ff7de23b67c50" },
"telescope.nvim": { "branch": "master", "commit": "54930e1abfc94409e1bb9266e752ef8379008592" },
"theme": { "branch": "main", "commit": "bc1f2151f23227ba02ac203c2c59ad693352a741" },
"trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" },
"true-zen.nvim": { "branch": "main", "commit": "2b9e210e0d1a735e1fa85ec22190115dffd963aa" },
"vim-fugitive": { "branch": "master", "commit": "854a8df0d06b8d3fcb30fa7f2b08c62b553eee3b" },
"vim-highlightedyank": { "branch": "master", "commit": "fa3f57b097e9521ce41a66b6c7cf5d9adea70ea3" },
"vim-illuminate": { "branch": "master", "commit": "3bd2ab64b5d63b29e05691e624927e5ebbf0fb86" },
"vim-tmux-navigator": { "branch": "master", "commit": "38b1d0402c4600543281dc85b3f51884205674b6" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}

23
lua/config/autocmds.lua Normal file
View File

@@ -0,0 +1,23 @@
-- auto-format on save
local lsp_fmt_group = vim.api.nvim_create_augroup("LspFormattingGroup", {})
vim.api.nvim_create_autocmd("BufWritePre", {
group = lsp_fmt_group,
callback = function()
local efm = vim.lsp.get_active_clients({ name = "efm" })
if vim.tbl_isempty(efm) then
return
end
vim.lsp.buf.format({ name = "efm", async = true })
end,
})
-- highlight on yank
local highlight_yank_group = vim.api.nvim_create_augroup("HighlightYankGroup", {})
vim.api.nvim_create_autocmd("TextYankPost", {
group = highlight_yank_group,
callback = function()
vim.highlight.on_yank()
end,
})

2
lua/config/globals.lua Normal file
View File

@@ -0,0 +1,2 @@
vim.g.mapleader = " "
vim.g.maplocalleader = " "

46
lua/config/init.lua Normal file
View File

@@ -0,0 +1,46 @@
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('config.globals')
require('config.options')
require('config.keymaps')
require('config.autocmds')
local plugins = "plugins"
local opts = {
defaults = {
lazy = true,
},
install = {
colorscheme = { "catppuccin" }
},
rtp = {
disabled_plugins = {
"gzip",
"matchit",
"matchparen",
"netrw",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
change_detection = {
notify = false,
},
}
require("lazy").setup('plugins', opts)

58
lua/config/keymaps.lua Normal file
View File

@@ -0,0 +1,58 @@
local mapkey = require("util.keymapper").mapvimkey
-- Buffer Navigation
mapkey("<leader>bn", "bnext", "n") -- Next buffer
mapkey("<leader>bp", "bprevious", "n") -- Prev buffer
mapkey("<leader>bb", "e #", "n") -- Switch to Other Buffer
mapkey("<leader>`", "e #", "n") -- Switch to Other Buffer
-- Directory Navigation
mapkey("<leader>m", "NvimTreeFocus", "n")
mapkey("<leader>e", "NvimTreeToggle", "n")
-- Pane and Window Navigation
mapkey("<C-h>", "<C-w>h", "n") -- Navigate Left
mapkey("<C-j>", "<C-w>j", "n") -- Navigate Down
mapkey("<C-k>", "<C-w>k", "n") -- Navigate Up
mapkey("<C-l>", "<C-w>l", "n") -- Navigate Right
mapkey("<C-h>", "wincmd h", "t") -- Navigate Left
mapkey("<C-j>", "wincmd j", "t") -- Navigate Down
mapkey("<C-k>", "wincmd k", "t") -- Navigate Up
mapkey("<C-l>", "wincmd l", "t") -- Navigate Right
mapkey("<C-h>", "TmuxNavigateLeft", "n") -- Navigate Left
mapkey("<C-j>", "TmuxNavigateDown", "n") -- Navigate Down
mapkey("<C-k>", "TmuxNavigateUp", "n") -- Navigate Up
mapkey("<C-l>", "TmuxNavigateRight", "n") -- Navigate Right
-- Window Management
mapkey("<leader>sv", "vsplit", "n") -- Split Vertically
mapkey("<leader>sh", "split", "n") -- Split Horizontally
mapkey("<C-Up>", "resize +2", "n")
mapkey("<C-Down>", "resize -2", "n")
mapkey("<C-Left>", "vertical resize +2", "n")
mapkey("<C-Right>", "vertical resize -2", "n")
-- Show Full File-Path
mapkey("<leader>pa", "echo expand('%:p')", "n") -- Show Full File Path
-- Notes
mapkey("<leader>ng", "Neorg workspace general", "n")
mapkey("<leader>nw", "Neorg workspace work", "n")
mapkey("<leader>ny", "Neorg workspace youtube", "n")
-- Indenting
vim.keymap.set("v", "<", "<gv", { silent = true, noremap = true })
vim.keymap.set("v", ">", ">gv", { silent = true, noremap = true })
local api = vim.api
-- Zen Mode
api.nvim_set_keymap("n", "<leader>zn", ":TZNarrow<CR>", {})
api.nvim_set_keymap("v", "<leader>zn", ":'<,'>TZNarrow<CR>", {})
api.nvim_set_keymap("n", "<leader>sm", ":TZFocus<CR>", {})
api.nvim_set_keymap("n", "<leader>zm", ":TZMinimalist<CR>", {})
api.nvim_set_keymap("n", "<leader>za", ":TZAtaraxis<CR>", {})
-- Comments
api.nvim_set_keymap("n", "<C-_>", "gtc", { noremap = false })
api.nvim_set_keymap("v", "<C-_>", "goc", { noremap = false })

50
lua/config/options.lua Normal file
View File

@@ -0,0 +1,50 @@
local opt = vim.opt
-- Tab / Indentation
opt.tabstop = 2
opt.shiftwidth = 2
opt.softtabstop = 2
opt.expandtab = true
opt.smartindent = true
opt.wrap = false
-- Search
opt.incsearch = true
opt.ignorecase = true
opt.smartcase = true
opt.hlsearch = false
-- Appearance
opt.number = true
opt.relativenumber = true
opt.termguicolors = true
opt.colorcolumn = '100'
opt.signcolumn = 'yes'
opt.cmdheight = 1
opt.scrolloff = 10
opt.completeopt = "menuone,noinsert,noselect"
-- Behaviour
opt.hidden = true
opt.errorbells = false
opt.swapfile = false
opt.backup = false
opt.undodir = vim.fn.expand("~/.vim/undodir")
opt.undofile = true
opt.backspace = "indent,eol,start"
opt.splitright = true
opt.splitbelow = true
opt.autochdir = false
opt.iskeyword:append("-")
opt.selection = "exclusive"
opt.mouse = "a"
opt.clipboard:append("unnamedplus")
opt.modifiable = true
opt.guicursor = "n-v-c:block,i-ci-ve:block,r-cr:hor20,o:hor50,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175"
opt.encoding = "UTF-8"
opt.showmode = false
-- folds
opt.foldmethod = "expr"
opt.foldexpr = "nvim_treesiter#foldexpr()"
opt.foldlevel = 99

14
lua/plugins/comment.lua Normal file
View File

@@ -0,0 +1,14 @@
return {
"numToStr/Comment.nvim",
opts = {
toggler = {
line = "gtc",
block = "gtb",
},
opleader = {
line = "goc",
block = "gob",
},
},
lazy = false,
}

56
lua/plugins/copilot.lua Normal file
View File

@@ -0,0 +1,56 @@
return {
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
dependencies = "zbirenbaum/copilot-cmp",
config = function()
require("copilot").setup(require("copilot").setup({
panel = {
enabled = true,
auto_refresh = false,
keymap = {
jump_prev = "[[",
jump_next = "]]",
accept = "<CR>",
refresh = "gr",
open = "<M-CR>",
},
layout = {
position = "bottom", -- | top | left | right
ratio = 0.4,
},
},
suggestion = {
enabled = true,
auto_trigger = true,
debounce = 75,
keymap = {
accept = "<M-l>",
accept_word = false,
accept_line = false,
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
},
filetypes = {
yaml = false,
markdown = false,
help = false,
gitcommit = false,
gitrebase = false,
hgcommit = false,
svn = false,
cvs = false,
["."] = false,
},
copilot_node_command = "node", -- Node.js version must be > 16.x
server_opts_overrides = {},
}))
require("copilot_cmp").setup({
formatters = {
insert_text = require("copilot_cmp.format").remove_existing,
},
})
end,
}

View File

@@ -0,0 +1,7 @@
return {
"lewis6991/gitsigns.nvim",
lazy = false,
config = function()
require("gitsigns").setup()
end
}

View File

@@ -0,0 +1,10 @@
return {
"m4xshen/hardtime.nvim",
command = "Hardtime",
event = "BufEnter",
dependencies = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
},
opts = {},
}

View File

@@ -0,0 +1,6 @@
return {
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
lazy = false,
opts = {},
}

4
lua/plugins/init.lua Normal file
View File

@@ -0,0 +1,4 @@
return {
{ "folke/neoconf.nvim", cmd = "Neoconf" },
"folke/neodev.nvim",
}

View File

@@ -0,0 +1,7 @@
return {
"ggandor/leap.nvim",
event = "BufEnter",
config = function()
require("leap").add_default_mappings()
end,
}

View File

@@ -0,0 +1,21 @@
return {
"glepnir/lspsaga.nvim",
lazy = false,
config = function()
require("lspsaga").setup({
-- keybinds for navigation in lspsaga window
move_in_saga = { prev = "<C-k>", next = "<C-j>" },
-- use enter to open file with finder
finder_action_keys = {
open = "<CR>",
},
-- use enter to open file with definition preview
definition_action_keys = {
edit = "<CR>",
},
})
end,
dependencies = {
"nvim-treesitter/nvim-treesitter",
},
}

View File

@@ -0,0 +1,24 @@
local config = function()
require("lualine").setup({
options = {
theme = "auto",
globalstatus = true,
component_separators = { left = "|", right = "|" },
section_separators = { left = "", right = "" },
},
sections = {
lualine_a = { "mode" },
lualine_b = { "buffers" },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
tabline = {},
})
end
return {
"nvim-lualine/lualine.nvim",
lazy = false,
config = config,
}

View File

@@ -0,0 +1,23 @@
local opts = {
ensure_installed = {
"efm",
"bashls",
"tsserver",
"solidity",
"tailwindcss",
"pyright",
"lua_ls",
"emmet_ls",
"jsonls",
"clangd",
},
automatic_installation = true,
}
return {
"williamboman/mason-lspconfig.nvim",
opts = opts,
event = "BufReadPre",
dependencies = "williamboman/mason.nvim",
}

14
lua/plugins/mason.lua Normal file
View File

@@ -0,0 +1,14 @@
return {
"williamboman/mason.nvim",
cmd = "Mason",
event = "BufReadPre",
opts = {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
},
}

26
lua/plugins/neorg.lua Normal file
View File

@@ -0,0 +1,26 @@
return {
{
"nvim-neorg/neorg",
build = ":Neorg sync-parsers",
dependencies = { "nvim-lua/plenary.nvim" },
lazy = false,
config = function()
require("neorg").setup({
load = {
["core.defaults"] = {}, -- Loads default behaviour
["core.concealer"] = {}, -- Adds pretty icons to your documents
["core.dirman"] = { -- Manages Neorg workspaces
config = {
workspaces = {
general = "~/Documents/Notes/general",
work = "~/Documents/Notes/work",
youtube = "~/Documents/Notes/youtube",
},
default_workspace = "general",
},
},
},
})
end,
},
}

8
lua/plugins/nightfox.lua Normal file
View File

@@ -0,0 +1,8 @@
return {
"EdenEast/nightfox.nvim",
lazy = false,
priority = 999,
config = function()
vim.cmd('colorscheme nightfox')
end
}

43
lua/plugins/noice.lua Normal file
View File

@@ -0,0 +1,43 @@
return {
"folke/noice.nvim",
event = "VeryLazy",
opts = {
routes = {
{
view = "notify",
filter = { event = "msg_showmode" },
},
},
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
-- you can enable a preset for easier configuration
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = false, -- add a border to hover docs and signature help
},
},
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",
-- config = function()
-- require("notify").setup({
-- background_colour = "#000000",
-- })
-- end,
-- },
},
}

View File

@@ -0,0 +1,5 @@
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
opts = {}, -- this is equalent to setup({}) function
}

54
lua/plugins/nvim-cmp.lua Normal file
View File

@@ -0,0 +1,54 @@
return {
"hrsh7th/nvim-cmp",
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
require("luasnip/loaders/from_vscode").lazy_load()
vim.opt.completeopt = "menu,menuone,noselect"
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
["<C-e>"] = cmp.mapping.abort(), -- close completion window
["<CR>"] = cmp.mapping.confirm({ select = false }),
}),
-- sources for autocompletion
sources = cmp.config.sources({
{ name = "nvim_lsp" }, -- lsp
{ name = "luasnip" }, -- snippets
{ name = "buffer" }, -- text within current buffer
{ name = "path" }, -- file system paths
}),
-- configure lspkind for vs-code like icons
formatting = {
format = lspkind.cmp_format({
maxwidth = 50,
ellipsis_char = "...",
}),
},
})
end,
dependencies = {
"onsails/lspkind.nvim",
{
"L3MON4D3/LuaSnip",
-- follow latest release.
version = "2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp",
},
},
}

View File

@@ -0,0 +1,11 @@
return {
"mfussenegger/nvim-dap-python",
ft = "python", -- filetype
config = function()
require("dap-python").setup("~/.local/share/nvim/mason/packages/debugpy/venv/bin/python")
end,
dependencies = {
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
},
}

39
lua/plugins/nvim-dap.lua Normal file
View File

@@ -0,0 +1,39 @@
local debugging_signs = require("util.icons").debugging_signs
return {
"mfussenegger/nvim-dap",
config = function()
local dap = require("dap")
local dapui = require("dapui")
-- set custom icons
for name, sign in pairs(debugging_signs) do
sign = type(sign) == "table" and sign or { sign }
vim.fn.sign_define(
"Dap" .. name,
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
)
end
-- setup dap
dapui.setup()
-- add event listeners
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
vim.cmd("Hardtime disable")
vim.cmd("NvimTreeClose")
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
vim.cmd("Hardtime enable")
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
vim.cmd("Hardtime enable")
end
end,
dependencies = "rcarriga/nvim-dap-ui",
}

View File

@@ -0,0 +1,202 @@
local on_attach = require("util.lsp").on_attach
local diagnostic_signs = require("util.icons").diagnostic_signs
local config = function()
require("neoconf").setup({})
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local lspconfig = require("lspconfig")
local capabilities = cmp_nvim_lsp.default_capabilities()
for type, icon in pairs(diagnostic_signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
-- lua
lspconfig.lua_ls.setup({
capabilities = capabilities,
on_attach = on_attach,
settings = { -- custom settings for lua
Lua = {
-- make the language server recognize "vim" global
diagnostics = {
globals = { "vim" },
},
workspace = {
-- make language server aware of runtime files
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
})
-- json
lspconfig.jsonls.setup({
capabilities = capabilities,
on_attach = on_attach,
filetypes = { "json", "jsonc" },
})
-- python
lspconfig.pyright.setup({
capabilities = capabilities,
on_attach = on_attach,
settings = {
pyright = {
disableOrganizeImports = false,
analysis = {
useLibraryCodeForTypes = true,
autoSearchPaths = true,
diagnosticMode = "workspace",
autoImportCompletions = true,
},
},
},
})
-- typescript
lspconfig.tsserver.setup({
on_attach = on_attach,
capabilities = capabilities,
filetypes = {
"typescript",
"javascript",
"typescriptreact",
"javascriptreact",
},
root_dir = lspconfig.util.root_pattern("package.json", "tsconfig.json", ".git"),
})
-- bash
lspconfig.bashls.setup({
capabilities = capabilities,
on_attach = on_attach,
filetypes = { "sh", "aliasrc" },
})
-- solidity
lspconfig.solidity.setup({
capabilities = capabilities,
on_attach = on_attach,
filetypes = { "solidity" },
})
-- typescriptreact, javascriptreact, css, sass, scss, less, svelte, vue
lspconfig.emmet_ls.setup({
capabilities = capabilities,
on_attach = on_attach,
filetypes = {
"typescriptreact",
"javascriptreact",
"javascript",
"css",
"sass",
"scss",
"less",
"svelte",
"vue",
"html",
},
})
-- docker
lspconfig.dockerls.setup({
capabilities = capabilities,
on_attach = on_attach,
})
-- C/C++
lspconfig.clangd.setup({
capabilities = capabilities,
on_attach = on_attach,
cmd = {
"clangd",
"--offset-encoding=utf-16",
},
})
local luacheck = require("efmls-configs.linters.luacheck")
local stylua = require("efmls-configs.formatters.stylua")
local flake8 = require("efmls-configs.linters.flake8")
local black = require("efmls-configs.formatters.black")
local eslint = require("efmls-configs.linters.eslint")
local prettier_d = require("efmls-configs.formatters.prettier_d")
local fixjson = require("efmls-configs.formatters.fixjson")
local shellcheck = require("efmls-configs.linters.shellcheck")
local shfmt = require("efmls-configs.formatters.shfmt")
local hadolint = require("efmls-configs.linters.hadolint")
local solhint = require("efmls-configs.linters.solhint")
local cpplint = require("efmls-configs.linters.cpplint")
local clangformat = require("efmls-configs.formatters.clang_format")
-- configure efm server
lspconfig.efm.setup({
filetypes = {
"lua",
"python",
"json",
"jsonc",
"sh",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"svelte",
"vue",
"markdown",
"docker",
"solidity",
"html",
"css",
"c",
"cpp",
},
init_options = {
documentFormatting = true,
documentRangeFormatting = true,
hover = true,
documentSymbol = true,
codeAction = true,
completion = true,
},
settings = {
languages = {
lua = { luacheck, stylua },
python = { flake8, black },
typescript = { eslint, prettier_d },
json = { eslint, fixjson },
jsonc = { eslint, fixjson },
sh = { shellcheck, shfmt },
javascript = { eslint, prettier_d },
javascriptreact = { eslint, prettier_d },
typescriptreact = { eslint, prettier_d },
svelte = { eslint, prettier_d },
vue = { eslint, prettier_d },
markdown = { prettier_d },
docker = { hadolint, prettier_d },
solidity = { solhint },
html = { prettier_d },
css = { prettier_d },
c = { clangformat, cpplint },
cpp = { clangformat, cpplint },
},
},
})
end
return {
"neovim/nvim-lspconfig",
config = config,
lazy = false,
dependencies = {
"windwp/nvim-autopairs",
"williamboman/mason.nvim",
"creativenull/efmls-configs-nvim",
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-nvim-lsp",
},
}

14
lua/plugins/nvim-tree.lua Normal file
View File

@@ -0,0 +1,14 @@
return {
"nvim-tree/nvim-tree.lua",
lazy = false,
config = function()
require("nvim-tree").setup({
filters = {
dotfiles = false,
},
view = {
adaptive_size = true,
},
})
end,
}

View File

@@ -0,0 +1,55 @@
local config = function()
require("nvim-treesitter.configs").setup({
build = ":TSUpdate",
indent = {
enable = true,
},
autotag = {
enable = true,
},
event = {
"BufReadPre",
"BufNewFile",
},
ensure_installed = {
"rust",
"markdown",
"json",
"javascript",
"typescript",
"yaml",
"html",
"css",
"markdown",
"bash",
"lua",
"dockerfile",
"solidity",
"gitignore",
"python",
"vue",
"svelte",
"toml",
},
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = true,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-s>",
node_incremental = "<C-s>",
scope_incremental = false,
node_decremental = "<BS>",
},
},
})
end
return {
"nvim-treesitter/nvim-treesitter",
lazy = false,
config = config,
}

View File

@@ -0,0 +1,4 @@
return {
"windwp/nvim-ts-autotag",
lazy = false,
}

View File

@@ -0,0 +1,3 @@
return {
"nvim-tree/nvim-web-devicons"
}

View File

@@ -0,0 +1,22 @@
local on_attach = require("util.lsp").on_attach
return {
"simrat39/rust-tools.nvim",
ft = "rust",
config = function()
local rt = require("rust-tools")
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local capabilities = cmp_nvim_lsp.default_capabilities()
rt.setup({
server = {
on_attach = on_attach,
capabilities = capabilities,
},
})
end,
dependencies = {
"neovim/nvim-lspconfig",
"nvim-lua/plenary.nvim",
"mfussenegger/nvim-dap",
},
}

View File

@@ -0,0 +1,9 @@
return {
"roobert/tailwindcss-colorizer-cmp.nvim",
-- optionally, override the default options:
config = function()
require("tailwindcss-colorizer-cmp").setup({
color_square_width = 2,
})
end,
}

45
lua/plugins/telescope.lua Normal file
View File

@@ -0,0 +1,45 @@
local mapvimkey = require("util.keymapper").mapvimkey
local config = function()
local telescope = require("telescope")
telescope.setup({
defaults = {
mappings = {
i = {
["<C-j>"] = "move_selection_next",
["<C-k>"] = "move_selection_previous",
},
},
},
pickers = {
find_files = {
theme = "dropdown",
previewer = true,
hidden = true,
},
live_grep = {
theme = "dropdown",
previewer = true,
},
buffers = {
theme = "dropdown",
previewer = true,
},
},
})
end
return {
"nvim-telescope/telescope.nvim",
tag = "0.1.3",
lazy = false,
dependencies = { "nvim-lua/plenary.nvim" },
config = config,
keys = {
mapvimkey("<leader>fk", "Telescope keymaps", "Show Keymaps"),
mapvimkey("<leader>fh", "Telescope help_tags", "Show Help Tags"),
mapvimkey("<leader>ff", "Telescope find_files", "Find Files"),
mapvimkey("<leader>fg", "Telescope live_grep", "Live Grep"),
mapvimkey("<leader>fb", "Telescope buffers", "Find Buffers"),
},
}

10
lua/plugins/theme.lua Normal file
View File

@@ -0,0 +1,10 @@
return {
"catppuccin/nvim",
name = "theme",
lazy = false,
priority = 999,
config = function()
vim.cmd("colorscheme catppuccin")
require("catppuccin").setup({})
end,
}

View File

@@ -0,0 +1,4 @@
return {
"christoomey/vim-tmux-navigator",
lazy = false,
}

View File

@@ -0,0 +1,37 @@
local diagnostic_signs = require("util.icons").diagnostic_signs
local maplazykey = require("util.keymapper").maplazykey
return {
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {
signs = {
-- icons / text used for a diagnostic
error = diagnostic_signs.Error,
warning = diagnostic_signs.Warn,
hint = diagnostic_signs.Hint,
information = diagnostic_signs.Info,
other = diagnostic_signs.Info,
},
},
keys = {
maplazykey("<leader>xx", function()
require("trouble").toggle()
end, "Toggle Trouble"),
maplazykey("<leader>xw", function()
require("trouble").toggle("workspace_diagnostics")
end, "Show Workspace Diagnostics"),
maplazykey("<leader>xd", function()
require("trouble").toggle("document_diagnostics")
end, "Show Document Diagnostics"),
maplazykey("<leader>xq", function()
require("trouble").toggle("quickfix")
end, "Toggle Quickfix List"),
maplazykey("<leader>xl", function()
require("trouble").toggle("loclist")
end, "Toggle Location List"),
maplazykey("gR", function()
require("trouble").toggle("lsp_references")
end, "Toggle LSP References"),
},
}

4
lua/plugins/true-zen.lua Normal file
View File

@@ -0,0 +1,4 @@
return {
"pocco81/true-zen.nvim",
lazy = false,
}

View File

@@ -0,0 +1,4 @@
return {
lazy = false,
"tpope/vim-fugitive",
}

View File

@@ -0,0 +1,4 @@
return {
"machakann/vim-highlightedyank",
lazy = false
}

View File

@@ -0,0 +1,7 @@
return {
"RRethy/vim-illuminate",
lazy = false,
config = function()
require('illuminate').configure({})
end
}

5
lua/plugins/whichkey.lua Normal file
View File

@@ -0,0 +1,5 @@
return {
"folke/which-key.nvim",
lazy = false,
opts = {},
}

18
lua/util/icons.lua Normal file
View File

@@ -0,0 +1,18 @@
local M = {}
M.debugging_signs = {
Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" },
Breakpoint = "",
BreakpointCondition = "",
BreakpointRejected = { "", "DiagnosticError" },
LogPoint = ".>",
}
M.diagnostic_signs = {
Error = "",
Warn = "",
Hint = "",
Info = "",
}
return M

69
lua/util/keymapper.lua Normal file
View File

@@ -0,0 +1,69 @@
local vim_modes = {
n = "n",
i = "i",
v = "v",
}
local default_opts = {
noremap = true,
silent = true,
}
--- @param opts (table|nil)
--- @return table
local get_opts = function(opts)
local all_opts = opts
if all_opts == nil then
all_opts = {}
end
for k, v in pairs(default_opts) do
all_opts[k] = all_opts[k] or v
end
return all_opts
end
--- @param vimmode (string|nil)
--- @return string
local get_mode = function(vimmode)
local modeString = vim_modes[vimmode]
if modeString == nil then
return "n"
else
return modeString
end
end
--- @param command (string)
--- @return string
local get_cmd_string = function(command)
return [[<cmd>]] .. command .. [[<CR>]]
end
--- @param keymaps string
--- @param command string
--- @param vimmode (string|nil)
--- @param options (table|nil)
--- @return nil
local mapvimkey = function(keymaps, command, vimmode, options)
local mode = get_mode(vimmode)
local lhs = keymaps
local rhs = get_cmd_string(command)
local opts = get_opts(options)
vim.keymap.set(mode, lhs, rhs, opts)
end
--- @param keymaps string
--- @param cmd (function|string)
--- @param desc (string|nil)
--- @return table
local maplazykey = function(keymaps, cmd, desc)
if type(cmd) ~= "function" then
cmd = get_cmd_string(cmd)
end
return { keymaps, cmd, desc = desc }
end
return {
mapvimkey = mapvimkey,
maplazykey = maplazykey,
}

27
lua/util/lsp.lua Normal file
View File

@@ -0,0 +1,27 @@
local mapkey = require("util.keymapper").mapvimkey
local M = {}
M.on_attach = function(client, bufnr)
local opts = { noremap = true, silent = true, buffer = bufnr }
mapkey("<leader>fd", "Lspsaga finder", "n", opts) -- go to definition
mapkey("<leader>gd", "Lspsaga peek_definition", "n", opts) -- peak definition
mapkey("<leader>gD", "Lspsaga goto_definition", "n", opts) -- go to definition
mapkey("<leader>ca", "Lspsaga code_action", "n", opts) -- see available code actions
mapkey("<leader>rn", "Lspsaga rename", "n", opts) -- smart rename
mapkey("<leader>D", "Lspsaga show_line_diagnostics", "n", opts) -- show diagnostics for line
mapkey("<leader>d", "Lspsaga show_cursor_diagnostics", "n", opts) -- show diagnostics for cursor
mapkey("<leader>pd", "Lspsaga diagnostic_jump_prev", "n", opts) -- jump to prev diagnostic in buffer
mapkey("<leader>nd", "Lspsaga diagnostic_jump_next", "n", opts) -- jump to next diagnostic in buffer
mapkey("K", "Lspsaga hover_doc", "n", opts) -- show documentation for what is under cursor
if client.name == "pyright" then
mapkey("<leader>oi", "PyrightOrganizeImports", "n", opts) -- organise imports
mapkey("<leader>db", "DapToggleBreakpoint", "n", opts) -- toggle breakpoint
mapkey("<leader>dr", "DapContinue", "n", opts) -- continue/invoke debugger
mapkey("<leader>dt", "lua require('dap-python').test_method()", "n", opts) -- run tests
end
end
return M

15
neoconf.json Normal file
View File

@@ -0,0 +1,15 @@
{
"neodev": {
"library": {
"enabled": true,
"plugins": true
}
},
"neoconf": {
"plugins": {
"lua_ls": {
"enabled": true
}
}
}
}