1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 03:14: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

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
}
}