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
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 = {},
}