Move to lua nvim conf

This commit is contained in:
2024-07-04 01:15:48 +02:00
parent ce37aebb10
commit 009b8e2413
2 changed files with 355 additions and 0 deletions

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

@@ -0,0 +1,355 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or 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
local pluginTable = {
"mattn/webapi-vim",
"scrooloose/syntastic",
"sheerun/vim-polyglot",
{"catppuccin/nvim", lazy=true, name="catppuccin"},
"simnalamburt/vim-mundo",
"elkowar/yuck.vim",
{"glacambre/firenvim",
lazy = not vim.g.started_by_firenvim,
build = function()
vim.fn["firenvim#install"](0)
end
},
--'honza/vim-snippets',
--'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
'vim-scripts/indentLine.vim',
'rhysd/git-messenger.vim',
'rhysd/committia.vim',
'junegunn/vim-easy-align',
"preservim/nerdcommenter",
"mg979/vim-visual-multi",
"airblade/vim-gitgutter",
{
"folke/twilight.nvim",
opts = {
dimming = {
alpha = 0.25, -- amount of dimming
-- we try to get the foreground from the highlight groups or fallback color
color = { "Normal", "#ffffff" },
term_bg = "#000000", -- if guibg=NONE, this will be used to calculate text color
inactive = false, -- when true, other windows will be fully dimmed (unless they contain the same buffer)
},
context = 10, -- amount of lines we will try to show around the current line
treesitter = true, -- use treesitter when available for the filetype
-- treesitter is used to automatically expand the visible text,
-- but you can further control the types of nodes that should always be fully expanded
expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
"function",
"method",
"table",
"if_statement",
},
exclude = {}, -- exclude these filetypes
}
},
{
"NeogitOrg/neogit",
dependencies = {
"nvim-lua/plenary.nvim", -- required
"sindrets/diffview.nvim", -- optional - Diff integration
-- Only one of these is needed, not both.
"nvim-telescope/telescope.nvim", -- optional
},
config = true
},
{"folke/zen-mode.nvim", opts={
window = {
backdrop = 0.95, -- shade the backdrop of the Zen window. Set to 1 to keep the same as Normal
-- height and width can be:
-- * an absolute number of cells when > 1
-- * a percentage of the width / height of the editor when <= 1
-- * a function that returns the width or the height
width = 120, -- width of the Zen window
height = 1, -- height of the Zen window
-- by default, no options are changed for the Zen window
-- uncomment any of the options below, or add other vim.wo options you want to apply
options = {
-- signcolumn = "no", -- disable signcolumn
-- number = false, -- disable number column
-- relativenumber = false, -- disable relative numbers
-- cursorline = false, -- disable cursorline
-- cursorcolumn = false, -- disable cursor column
-- foldcolumn = "0", -- disable fold column
-- list = false, -- disable whitespace characters
},
},
plugins = {
-- disable some global vim options (vim.o...)
-- comment the lines to not apply the options
options = {
enabled = true,
ruler = false, -- disables the ruler text in the cmd line area
showcmd = false, -- disables the command in the last line of the screen
-- you may turn on/off statusline in zen mode by setting 'laststatus'
-- statusline will be shown only if 'laststatus' == 3
laststatus = 0, -- turn off the statusline in zen mode
},
twilight = { enabled = true }, -- enable to start Twilight when zen mode opens
gitsigns = { enabled = false }, -- disables git signs
tmux = { enabled = false }, -- disables the tmux statusline
-- this will change the font size on kitty when in zen mode
-- to make this work, you need to set the following kitty options:
-- - allow_remote_control socket-only
-- - listen_on unix:/tmp/kitty
kitty = {
enabled = true,
font = "+4", -- font size increment
},
-- this will change the font size on alacritty when in zen mode
-- requires Alacritty Version 0.10.0 or higher
-- uses `alacritty msg` subcommand to change font size
alacritty = {
enabled = false,
font = "14", -- font size
},
-- this will change the font size on wezterm when in zen mode
-- See alse also the Plugins/Wezterm section in this projects README
wezterm = {
enabled = false,
-- can be either an absolute font size or the number of incremental steps
font = "+4", -- (10% increase per step)
},
},
}},
--'vim-airline/vim-airline'
--'vim-airline/vim-airline-themes'
--'ctrlpvim/ctrlp.vim'
--'godlygeek/tabular'
--'easymotion/vim-easymotion'
--'nathanaelkane/vim-indent-guides'
--'xuyuanp/nerdtree-git-plugin'
--'bronson/vim-trailing-whitespace'
--'tpope/vim-dadbod'
--'tpope/vim-eunuch'
--'tpope/vim-speeddating'
--'tpope/vim-repeat'
--'tpope/vim-rhubarb'
--'tpope/vim-unimpaired'
--'tpope/vim-abolish'
--'tpope/vim-obsession'
--'tpope/vim-fugitive'
--'tpope/vim-surround'
{
'Exafunction/codeium.vim',
event = 'BufEnter',
config = function ()
-- Change '<C-g>' here to any keycode you like.
vim.keymap.set('i', '<C-g>', function () return vim.fn['codeium#Accept']() end, { expr = true, silent = true })
vim.keymap.set('i', '<c-;>', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true, silent = true })
vim.keymap.set('i', '<c-,>', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true, silent = true })
vim.keymap.set('i', '<c-x>', function() return vim.fn['codeium#Clear']() end, { expr = true, silent = true })
end
},
--'lambdalisue/suda.vim'
{'nvim-treesitter/nvim-treesitter', build = ':TSUpdate'},
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim',
'kosayoda/nvim-lightbulb',
--'antoinemadec/FixCursorHold.nvim'
'mhartington/formatter.nvim',
'NvChad/nvim-colorizer.lua',
{'ms-jpq/chadtree', branch='chad', build='python3 -m chadtree deps'},
{'ms-jpq/coq_nvim', branch='coq'},
--" 9000+ Snippets
{'ms-jpq/coq.artifacts', branch='artifacts'},
{'ms-jpq/coq.thirdparty', branch='3p'},
'nvim-tree/nvim-web-devicons',
'projekt0n/circles.nvim',
'nvim-neotest/nvim-nio',
--'uga-rosa/translate.nvim'
--'mechatroner/rainbow_csv'
--'christoomey/vim-system-copy'
--'eandrju/cellular-automaton.nvim'
--"neovim/nvim-lspconfig",
--"'ranjithshegde/ccls.nvim'
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
"folke/neodev.nvim",
"folke/which-key.nvim",
{ "folke/neoconf.nvim", cmd = "Neoconf" },
{"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
{ "folke/neodev.nvim", opts = {} },
}, },
}
vim.opt.rtp:prepend(lazypath)
require("lazy").setup(pluginTable)
--vim.g.limelight_conceal_ctermfg = "DarkGray"
--vim.g.limelight_conceal_guifg = {"DarkGray", "#777777"}
--autocmd CursorHold,CursorHoldI * lua require('nvim-lightbulb').update_lightbulb()
--if has("persistent_undo")
--let target_path = expand('~/.nvimundodir')
--" create the directory and any parent directories
--" if the location does not exist.
--if !isdirectory(target_path)
--call mkdir(target_path, "p", 0700)
--endif
--let &undodir=target_path
--set undofile
--endif
vim.api.nvim_create_autocmd("StdinReadPre", {
pattern = "*",
command = "let s:std_in=1"
})
vim.api.nvim_create_autocmd("VimEnter", {
pattern = "*",
command = "if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | execute 'CHADopen' | execute 'cd '.argv()[0] | endif"
})
vim.g.airline_powerline_fonts = 1
--vim.g.coq_settings = {'clients.tabnine.enabled' = false}
--filetype plugin on
--vim.g.syntastic_python_python_exec = 'python3'
--vim.g.syntastic_python_checkers = ['bandit', 'python']
--" Keybinds
vim.keymap.set('n', '<F2>', ':CHADopen<CR>',{noremap=true})
vim.keymap.set('n', '<F3>', function() vim.lsp.buf.code_action() end,{noremap=true})
vim.keymap.set('n', '<F4>', ':ZenMode<CR>',{noremap=true})
--nnoremap <F2> :CHADopen<CR>
--nnoremap <F3> :lua vim.lsp.buf.code_action()<CR>
--nnoremap <F4> :Goyo<CR>
--nnoremap <F5> :MundoToggle<CR>
--nnoremap <F6> :lua require("dapui").toggle()<CR>
require("neodev").setup({
override = function(_, library)
library.enabled = true
library.plugins = true
end,
})
require("mason").setup()
require("mason-lspconfig").setup()
require("mason-lspconfig").setup_handlers({
function (server_name) -- default handler (optional)
require("lspconfig")[server_name].setup(require('coq').lsp_ensure_capabilities({}))
end})
local lsp = require "lspconfig"
local coq = require "coq" -- add this
local dap = require("dap")
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "-i", "dap" }
}
dap.configurations.cpp = {
{
name = "Launch",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
}
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
end
local lsp_flags = {
-- This is the default in Nvim 0.7+
debounce_text_changes = 150,
}
--lsp.<server>.setup(<stuff...>) -- before
--lsp.<server>.setup(coq.lsp_ensure_capabilities(<stuff...>)) -- after
--lsp.pyright.setup(coq.lsp_ensure_capabilities({}))
--lsp.ccls.setup(coq.lsp_ensure_capabilities({}))
--lsp.ltex.setup(coq.lsp_ensure_capabilities({settings = {ltex = {language = "pl-PL"}}}))
lsp.rust_analyzer.setup(coq.lsp_ensure_capabilities({
settings = {
["rust-analyzer"] = {
imports = {
granularity = {
group = "module",
},
prefix = "self",
},
cargo = {
buildScripts = {
enable = true,
},
},
procMacro = {
enable = true
},
}
}
}))
vim.g.catppuccin_flavour = "macchiato"
require("dapui").setup()
require("catppuccin").setup()
require('colorizer').setup()
require("circles").setup()
vim.cmd.colorscheme "catppuccin"
vim.api.nvim_create_autocmd('VimEnter',
{callback =
function()
vim.api.nvim_command("COQnow -s")
end,
})
--autocmd VimEnter * execute 'COQnow -s'