This commit is contained in:
don philipe
2025-01-23 09:41:17 +01:00
18 changed files with 232 additions and 2 deletions

View File

@@ -1,4 +1,3 @@
[colors.cursor]
cursor = "#00ff00"
text = "#000000"

12
.config/nvim/init.lua Normal file
View File

@@ -0,0 +1,12 @@
require("config.remap")
require("config.set")
-- plugin manager
require("config.lazy")
-- plugins
require("config.cmp")
require("config.gen-private")
require("config.lsp")
require("config.mason")
require("config.treesitter")

View File

@@ -0,0 +1,27 @@
-- autocompletion
local cmp = require('cmp')
cmp.setup({
sources = {
{name = 'nvim_lsp'},
},
mapping = cmp.mapping.preset.insert({
-- Navigate between completion items
['<C-p>'] = cmp.mapping.select_prev_item({behavior = 'select'}),
['<C-n>'] = cmp.mapping.select_next_item({behavior = 'select'}),
-- `Enter` key to confirm completion
['<CR>'] = cmp.mapping.confirm({select = false}),
-- Ctrl+Space to trigger completion menu
['<C-Space>'] = cmp.mapping.complete(),
-- Scroll up and down in the completion documentation
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
}),
snippet = {
expand = function(args)
vim.snippet.expand(args.body)
end,
},
})

View File

@@ -0,0 +1,38 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
},
true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
-- Open lazy menu with :Lazy check

View File

@@ -0,0 +1,32 @@
-- Reserve a space in the gutter
-- This will avoid an annoying layout shift in the screen
vim.opt.signcolumn = 'yes'
-- Add cmp_nvim_lsp capabilities settings to lspconfig
-- This should be executed before you configure any language server
local lspconfig_defaults = require('lspconfig').util.default_config
lspconfig_defaults.capabilities = vim.tbl_deep_extend(
'force',
lspconfig_defaults.capabilities,
require('cmp_nvim_lsp').default_capabilities()
)
-- This is where you enable features that only work
-- if there is a language server active in the file
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions',
callback = function(event)
local opts = {buffer = event.buf}
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
end,
})

View File

@@ -0,0 +1,9 @@
require('mason').setup({})
require('mason-lspconfig').setup({
handlers = {
function(server_name)
require('lspconfig')[server_name].setup({})
end,
},
})
-- install language servers via :LspInstall

View File

@@ -0,0 +1,16 @@
-- Custom remappings
-- paste buffer and dont replace buffer content with what has been pasted over (but put it to "void" buffer)
vim.keymap.set("x", "<leader>p", "\"_dP")
-- tab creation, navigation and closing
vim.keymap.set("n", "<C-t>", ":tabnew<CR>")
vim.keymap.set("n", "<C-h>", ":tabprevious<CR>")
vim.keymap.set("n", "<C-l>", ":tabnext<CR>")
vim.keymap.set("n", "<C-x>", ":tabclose<CR>")
-- resize windows with arrow keys
vim.keymap.set("n", "<Up>", ":resize -1<CR>")
vim.keymap.set("n", "<Down>", ":resize +1<CR>")
vim.keymap.set("n", "<Left>", ":vertical resize -1<CR>")
vim.keymap.set("n", "<Right>", ":vertical resize +1<CR>")

View File

@@ -0,0 +1,13 @@
-- Custom settings
vim.opt.guicursor = ""
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.scrolloff = 8
vim.opt.incsearch = true
vim.opt.signcolumn = "yes"

View File

@@ -0,0 +1,37 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the listed parsers MUST always be installed)
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline", "python", "javascript", "css", "html", "yaml", "java", "bash", "csv", "dockerfile", "htmldjango", "json", "nginx" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (or "all")
--ignore_install = { "javascript" },
highlight = {
enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
--disable = { "c", "rust" },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
--disable = function(lang, buf)
-- local max_filesize = 100 * 1024 -- 100 KB
-- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
-- if ok and stats and stats.size > max_filesize then
-- return true
-- end
--end,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}

View File

@@ -0,0 +1,3 @@
return {
{'neovim/nvim-cmp'}
}

View File

@@ -0,0 +1,13 @@
local ok, vars = pcall(require, 'config.gen-private')
if not ok then
print("Missing gen-private configuration file.")
end
return {
{ "David-Kunz/gen.nvim",
opts = {
model = vars["model"],
host = vars["host"],
port = vars["port"],
}},
}

View File

@@ -0,0 +1,3 @@
return {
{'morhetz/gruvbox', config = function() vim.cmd.colorscheme("gruvbox") end }
}

View File

@@ -0,0 +1,5 @@
return {
{'neovim/nvim-lspconfig'},
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/nvim-cmp'},
}

View File

@@ -0,0 +1,6 @@
return {
-- mason for downloading language servers
{'williamboman/mason.nvim'},
-- mason-lspconfig to configure auto setup of language servers
{'williamboman/mason-lspconfig.nvim'},
}

View File

@@ -0,0 +1,9 @@
-- plugins form the "mini" plugin set https://github.com/echasnovski/mini.nvim?tab=readme-ov-file#modules
return {
-- auto-insert closing brackets etc.
{
'echasnovski/mini.pairs',
event = 'InsertEnter', -- lazy loading (when entering insert mode)
config = true, -- shorthand for calling plugins setup function
},
}

View File

@@ -0,0 +1,5 @@
return {
{'nvim-treesitter/nvim-treesitter'}
-- configure parsers via config/treesitter.lua
-- update parsers with :TSUpdate
}