1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 11:24:55 +02:00

Update nvim config

This commit is contained in:
Henrik Hautakoski 2023-11-22 14:19:13 +01:00
parent d7a1770460
commit 461e0cc49a
27 changed files with 426 additions and 2999 deletions

22
nvim/lua/config/base.lua Normal file
View file

@ -0,0 +1,22 @@
--
-- General Settings
--
vim.opt.showmode = false -- disable mode in the command line, because i use lualine
--vim.opt.guicursor = "a:ver100,c-ci-cr:hor80-blinkon100-blinkwait300"
--vim.opt.scrolloff = 30
--vim.opt.sidescrolloff = 8
--
-- Editor settings
--
vim.opt.cursorline = true -- highlight line where cursor is.
-- line numbers
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.numberwidth = 6
-- indent
vim.opt.smartindent = true

View file

@ -0,0 +1,31 @@
local autocmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup
local set = vim.opt
set.tabstop = 4
set.softtabstop = 4
set.shiftwidth = 4
set.autoindent = true
augroup('indent', { clear = true })
-- Hardtabs for make
autocmd('Filetype', {
group = 'indent',
pattern = { 'make' },
command = 'setlocal ts=4 sts=0 sw=4 noexpandtab'
})
-- Softtab (2) for yaml
autocmd('Filetype', {
group = 'indent',
pattern = { 'yaml' },
command = 'setlocal ts=2 sts=2 sw=2 expandtab'
})
-- Hardtabs for c/cpp
autocmd('Filetype', {
group = 'indent',
pattern = { 'c', 'cpp' },
command = 'setlocal ts=8 sts=0 sw=8 noexpandtab'
})

3
nvim/lua/config/init.lua Normal file
View file

@ -0,0 +1,3 @@
require("config.base")
require("config.keybinds")
require("config.indent")

View file

@ -0,0 +1,39 @@
-- Basic ones
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set("i", "<C-z>", vim.cmd.undo)
vim.keymap.set("i", "<C-y>", vim.cmd.redo)
-- Ctrl+s saves the current buffer in normal/insert mode.
vim.keymap.set("n", "<C-s>", vim.cmd.w)
vim.keymap.set("i", "<C-s>", vim.cmd.w)
-- Disable arrow keys (force me to use hjkl)
vim.keymap.set("n", "<Up>", "", { noremap=true })
vim.keymap.set("n", "<Down>", "", { noremap=true })
vim.keymap.set("n", "<Left>", "", { noremap=true })
vim.keymap.set("n", "<Right>", "", { noremap=true })
vim.keymap.set("i", "<Up>", "", { noremap=true })
vim.keymap.set("i", "<Down>", "", { noremap=true })
vim.keymap.set("i", "<Left>", "", { noremap=true })
vim.keymap.set("i", "<Right>", "", { noremap=true })
vim.keymap.set("v", "<Up>", "", { noremap=true })
vim.keymap.set("v", "<Down>", "", { noremap=true })
vim.keymap.set("v", "<Left>", "", { noremap=true })
vim.keymap.set("v", "<Right>", "", { noremap=true })
-- Move Text
--vim.keymap.set("n", "<S-a>", ":m+1<CR>")
--vim.keymap.set("v", "<S-d>", ":m-2<CR>")
--vim.keymap.set("v", "<S-a>", ":m+1<CR>")
--vim.keymap.set("n", "<S-d>", ":m-2<CR>")
-- Indent
-- Make Shift-Tab undo indent.
vim.keymap.set("i", "<S-Tab>", "<C-d>")

64
nvim/lua/plugins/cmp.lua Normal file
View file

@ -0,0 +1,64 @@
return {
'hrsh7th/nvim-cmp',
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-nvim-lsp-signature-help',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'L3MON4D3/LuaSnip',
'onsails/lspkind-nvim',
},
config = function()
local cmp = require('cmp')
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp.setup({
preselect = false,
view = {
entries = { name = 'custom', selection_order = 'near_cursor' },
},
mapping = {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
['<CR>'] = cmp.mapping.confirm({ select = false }),
},
formatting = {
format = function(entry, vim_item)
if vim.tbl_contains({ 'path' }, entry.source.name) then
local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label)
if icon then
vim_item.kind = icon
vim_item.kind_hl_group = hl_group
return vim_item
end
end
return require('lspkind').cmp_format({ with_text = true })(entry, vim_item)
end
},
sources = {
{ name = 'nvim_lsp', max_item_count = 10 },
{ name = 'nvim_lsp_signature_help' },
{ name = 'buffer' },
{ name = 'path' },
},
})
end
}

View file

@ -0,0 +1,9 @@
return {
"rebelot/kanagawa.nvim",
lazy = false,
priority = 1000,
config = function()
require("kanagawa").load("wave")
end
}

View file

@ -0,0 +1,12 @@
return {
'lewis6991/gitsigns.nvim',
lazy = false,
opts = {
signs = {
add = { text = '+' },
delete = { text = '-' },
change = { text = '~' },
untracked = { text = '+'}
},
},
}

41
nvim/lua/plugins/init.lua Normal file
View file

@ -0,0 +1,41 @@
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({
-- Highlight
--{ import = "plugins.kodex" },
{ import = "plugins.colortheme-kanagawa" },
-- Status line
{ import = "plugins.lualine" },
-- Fuzzy finder
{ import = "plugins.telescope" },
-- Keybind helper
-- { import = "plugins.which-key" },
-- Treesitter
{ import = "plugins.treesitter" },
-- Complete
-- { import = "plugins.cmp" },
-- LSP
{ import = "plugins.lsp" },
-- Git changes in gutter
--{ import = "plugins.gitsigns" },
})

View file

@ -0,0 +1,8 @@
return {
dir = "~/code/misc/kodex.nvim",
lazy = false,
priority = 1000,
config = function()
vim.cmd(":colorscheme kodex-arctic")
end
}

40
nvim/lua/plugins/lsp.lua Normal file
View file

@ -0,0 +1,40 @@
return {
'neovim/nvim-lspconfig',
dependencies = {
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
require('plugins.cmp')
},
config = function()
-- Setup Mason to automatically install LSP servers
require('mason').setup()
require('mason-lspconfig').setup({ automatic_installation = true })
-- local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
-- PHP
require('lspconfig').intelephense.setup({
commands = {
IntelephenseIndex = {
function() vim.lsp.buf.execute_command({ command = 'intelephense.index.workspace' }) end,
},
},
on_attach = function(client, bufnr)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
-- capabilities = capabilities
})
-- Tailwind CSS
--require('lspconfig').tailwindcss.setup({ capabilities = capabilities })
-- Config
-- Sign configuration
vim.fn.sign_define('DiagnosticSignError', { text = '', texthl = 'DiagnosticSignError' })
vim.fn.sign_define('DiagnosticSignWarn', { text = '', texthl = 'DiagnosticSignWarn' })
vim.fn.sign_define('DiagnosticSignInfo', { text = '', texthl = 'DiagnosticSignInfo' })
vim.fn.sign_define('DiagnosticSignHint', { text = '', texthl = 'DiagnosticSignHint' })
end
}

View file

@ -0,0 +1,26 @@
return {
'nvim-lualine/lualine.nvim',
event = "VeryLazy",
dependencies = {
'arkav/lualine-lsp-progress',
'kyazdani42/nvim-web-devicons',
},
opts = {
options = {
component_separators = '',
globalstatus = true,
},
sections = {
lualine_x = {
{
require("lazy.status").updates,
cond = require("lazy.status").has_updates,
color = { fg = "#ff9e64" },
}
},
lualine_y = {
'encoding', 'fileformat', 'filetype'
}
},
}
}

View file

@ -0,0 +1,2 @@
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif

View file

@ -0,0 +1,30 @@
return {
'nvim-telescope/telescope.nvim',
tag = '0.1.4',
dependencies = {
'nvim-lua/plenary.nvim',
'kyazdani42/nvim-web-devicons'
},
keys = {
{ '<leader>f', function() require('telescope.builtin').find_files() end },
{ '<leader>F', function() require('telescope.builtin').git_files() end },
},
config = function()
require('telescope').setup({
defaults = {
path_display = { truncate = 1 },
prompt_prefix = ' ',
selection_caret = ' ',
file_ignore_patterns = {
".git/",
"node_modules/"
},
},
pickers = {
find_files = {
hidden = true
},
},
})
end
}

View file

@ -0,0 +1,60 @@
return {
'nvim-treesitter/nvim-treesitter',
build = function()
require('nvim-treesitter.install').update({ with_sync = true })
end,
dependencies = {
'nvim-treesitter/playground'
},
opts = {
-- A list of parser names
ensure_installed = {
"c",
"cpp",
"ninja",
"cmake",
"lua",
"vim",
"vimdoc",
"query",
"php",
"go",
"javascript",
"typescript",
"css",
"scss",
"html",
"vue",
"json",
"yaml",
"toml",
"xml",
"glsl",
"hlsl"
},
-- 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,
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
enable = true,
-- 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,
},
indent = {
enable = true
}
}
}

View file

@ -0,0 +1,14 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}