feat!: major rework

This commit is contained in:
fiplox 2023-06-19 11:33:42 +02:00
parent a38625b342
commit e39a7af386
11 changed files with 134 additions and 402 deletions

View File

@ -16,10 +16,10 @@ vim.opt.runtimepath:prepend(lazypath)
vim.api.nvim_create_autocmd('User', {
pattern = 'LazyVimStarted',
callback = function()
require 'feline'
require 'lualine'
require 'config.mappings'
require 'config.autocmd'
require 'noice'
-- require 'noice'
require 'nvim-treesitter'
vim.cmd 'colorscheme neogruber'
end,

View File

@ -64,6 +64,7 @@ vim.api.nvim_create_autocmd('FileType', {
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
vim.opt_local.textwidth = 80
end,
})
function ToggleTroubleAuto()

View File

@ -20,10 +20,10 @@ keymap('n', '<home>', '<cmd>ToggleTerm direction=horizontal<cr>', opt)
keymap('t', '<home>', '<cmd>ToggleTerm direction=horizontal<cr>', opt)
keymap('v', '<home>', '<cmd>ToggleTerm direction=horizontal<cr>', opt)
keymap('i', '<home>', '<cmd>ToggleTerm direction=horizontal<cr>', opt)
keymap('n', '<end>', '<cmd>ToggleTerm direction=vertical<cr>', opt)
keymap('t', '<end>', '<cmd>ToggleTerm direction=vertical<cr>', opt)
keymap('v', '<end>', '<cmd>ToggleTerm direction=vertical<cr>', opt)
keymap('i', '<end>', '<cmd>ToggleTerm direction=vertical<cr>', opt)
keymap('n', '<end>', '<cmd>ToggleTerm direction=float<cr>', opt)
keymap('t', '<end>', '<cmd>ToggleTerm direction=float<cr>', opt)
keymap('v', '<end>', '<cmd>ToggleTerm direction=float<cr>', opt)
keymap('i', '<end>', '<cmd>ToggleTerm direction=float<cr>', opt)
-- }}}
keymap('n', '<BS>', ':', { noremap = true })
@ -96,7 +96,17 @@ function UnMapDHM()
vim.api.nvim_del_keymap('n', 'N')
end
MapDHM()
local function file_exists(name)
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
return true
else return false end
end
if file_exists('/tmp/colemak') then
MapDHM()
end
local wk = require 'which-key'
@ -129,12 +139,12 @@ wk.setup {
padding = { 1, 1, 1, 1 }, -- extra window padding [top, right, bottom, left]
},
layout = {
height = { min = 4, max = 25 }, -- min and max height of the columns
width = { min = 20, max = 50 }, -- min and max width of the columns
spacing = 3, -- spacing between columns
height = { min = 4, max = 25 }, -- min and max height of the columns
width = { min = 20, max = 50 }, -- min and max width of the columns
spacing = 3, -- spacing between columns
},
hidden = { '<silent>', '<cmd>', '<Cmd>', '<CR>', 'call', 'lua', '^:', '^ ' }, -- hide mapping boilerplate
show_help = true, -- show help message on the command line when the popup is visible
show_help = true, -- show help message on the command line when the popup is visible
}
local opts = {
@ -159,6 +169,7 @@ local mappings = {
['f'] = { '<cmd>e ~/.config/nvim/ <cr>', 'Neovim config' },
['rr'] = 'Search and replace all',
['rs'] = 'Search and replace',
['c'] = { '<cmd>lua UnMapDHM()<cr>', 'Qwerty' },
['b'] = {
function()
require('buffer_manager.ui').toggle_quick_menu()
@ -211,6 +222,7 @@ local mappings = {
['g'] = { '<cmd>Neogit<cr>', 'Neogit' },
l = {
name = 'LSP',
l = { '<cmd>Lazy load lsp <bar> LspStart <cr>', 'Start LSP' },
f = { '<cmd>lua vim.lsp.buf.format { async = true }<cr>', 'Format' },
i = 'Lsp Info',
a = 'Code action',

View File

@ -5,40 +5,27 @@ g.mapleader = ' '
g.tex_flavor = 'latex'
g.c_syntax_for_h = true
--opt.wildoptions = true -- TODO: see how it works
opt.termguicolors = true
opt.guicursor = 'n-v-c-sm:hor20,i-ci-ve:ver20,r-cr-o:Block'
opt.mouse = 'nv'
opt.path = '.,,**h'
-- opt.pumheight = 10 -- TODO: probably to change
opt.fileencoding = 'utf-8'
opt.splitbelow = true
opt.splitright = true
opt.smartindent = false -- TODO: maybe?
opt.showmode = false
opt.undofile = true
opt.updatetime = 300
opt.backup = false
opt.clipboard:prepend { 'unnamedplus' }
opt.ignorecase = true
opt.smartcase = true
opt.cursorline = true
opt.sessionoptions = 'folds'
opt.foldmethod = 'marker'
opt.foldlevel = 0
opt.number = true
opt.hidden = true
opt.shortmess:append('I', 'W', 's')
-- opt.scrolloff = 15 -- TODO: maybe ?
opt.iskeyword:prepend { '-' }
opt.inccommand = 'nosplit'
opt.completeopt:append 'menuone'
opt.timeoutlen = 300
opt['foldenable'] = false
opt.fillchars = 'eob: '
opt.cmdheight = 1
opt.cmdheight = 0
opt.grepprg = 'rg --vimgrep --no-heading --smart-case --hidden'
opt.grepformat = '%f:%l:%c:%m'
-- opt.autochdir = true
vim.api.nvim_create_user_command('Cd', 'lcd %:p:h', { nargs = 0 })

View File

@ -1,242 +1,11 @@
local M = {}
M.kind_icons = {
Text = '',
Method = '',
Function = '',
Constructor = '',
Field = '',
Variable = '',
Class = '',
Interface = '',
Module = '',
Property = '',
Unit = '',
Value = '',
Enum = '',
Keyword = '',
Snippet = '',
Color = '',
File = '',
Reference = '',
Folder = '',
EnumMember = '',
Constant = '',
Struct = '',
Event = '',
Operator = '',
TypeParameter = '',
}
M.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
M.feline_theme = {
fg = '#c9d1d9',
bg = '#1f2428',
green = '#66cc66',
yellow = '#d5992a',
purple = '#c678dd',
orange = '#b17135',
peanut = '#f6d5a4',
red = '#e06c75',
aqua = '#61afef',
bg2 = '#24293a',
dark_red = '#f75f5f',
}
M.feline_vi_mode_colors = {
NORMAL = 'green',
OP = 'green',
INSERT = 'yellow',
VISUAL = 'purple',
LINES = 'orange',
BLOCK = 'dark_red',
REPLACE = 'red',
COMMAND = 'aqua',
}
M.feline_c = {
vim_mode = {
provider = {
name = 'vi_mode',
opts = {
show_mode_name = true,
-- padding = "center", -- Uncomment for extra padding.
},
},
hl = function()
return {
fg = require('feline.providers.vi_mode').get_mode_color(),
bg = 'bg2',
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
left_sep = 'block',
right_sep = 'block',
},
gitBranch = {
provider = 'git_branch',
hl = {
fg = 'peanut',
bg = 'bg2',
style = 'bold',
},
left_sep = 'block',
right_sep = 'block',
},
gitDiffAdded = {
provider = 'git_diff_added',
hl = {
fg = 'green',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitDiffRemoved = {
provider = 'git_diff_removed',
hl = {
fg = 'red',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitDiffChanged = {
provider = 'git_diff_changed',
hl = {
fg = 'fg',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'right_filled',
},
separator = {
provider = '',
},
file_info = {
provider = {
name = 'file_info',
opts = {
colored_icon = false,
type = 'relative-short',
},
},
hl = {
style = 'bold',
},
left_sep = ' ',
right_sep = ' ',
},
diagnostic_errors = {
provider = 'diagnostic_errors',
hl = {
fg = 'red',
},
},
diagnostic_warnings = {
provider = 'diagnostic_warnings',
hl = {
fg = 'yellow',
},
},
diagnostic_hints = {
provider = 'diagnostic_hints',
hl = {
fg = 'aqua',
},
},
diagnostic_info = {
provider = 'diagnostic_info',
},
lsp_client_names = {
provider = 'lsp_client_names',
hl = {
fg = 'purple',
bg = 'bg2',
style = 'bold',
},
left_sep = 'left_filled',
right_sep = 'right_filled',
},
file_type = {
provider = {
name = 'file_type',
opts = {
-- filetype_icon = true,
colored_icon = false,
case = 'titlecase',
},
},
hl = {
fg = 'red',
bg = 'bg2',
style = 'bold',
},
left_sep = 'left_filled',
right_sep = 'block',
},
file_encoding = {
provider = 'file_encoding',
hl = {
fg = 'orange',
bg = 'bg2',
-- style = 'italic',
},
left_sep = 'block',
right_sep = 'block',
},
position = {
provider = 'position',
hl = {
fg = 'green',
bg = 'bg2',
style = 'bold',
},
left_sep = 'block',
right_sep = 'block',
},
line_percentage = {
provider = 'line_percentage',
hl = {
fg = 'aqua',
bg = 'bg2',
style = 'bold',
},
left_sep = 'block',
right_sep = 'block',
},
scroll_bar = {
provider = 'scroll_bar',
hl = {
fg = 'yellow',
style = 'bold',
},
},
search_count = {
provider = 'search_count',
hl = {
style = 'bold',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
macro = {
provider = 'macro',
hl = {
style = 'bold',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
}
function M.on_attach(client, bufnr)
--[=[ function M.on_attach(client, bufnr)
--[[ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') ]]
if client.name == 'jdt.ls' then
client.server_capabilities.documentFormattingProvider = false
@ -258,8 +27,9 @@ function M.on_attach(client, bufnr)
-- util.info(client.name .. " " .. (enable and "yes" or "no"), "format")
client.server_capabilities.documentFormattingProvider = enable
client.server_capabilities.semanticTokensProvider = false
end
-- client.server_capabilities.semanticTokensProvider = false
client.server_capabilities.semanticTokensProvider = nil
end ]=]
M.lsp_config = {
virtual_text = {

View File

@ -47,8 +47,8 @@ return {
fields = { 'abbr', 'kind', 'menu' },
format = function(_, item)
local ELLIPSIS_CHAR = ''
local MAX_LABEL_WIDTH = 20
item.kind = string.format('%s %s', utils.kind_icons[item.kind], item.kind) -- This concatonates the icons with the name of the item kind
local MAX_LABEL_WIDTH = 25
item.kind = string.format('%s', item.kind) -- This concatonates the icons with the name of the item kind
local label = item.abbr
local truncated_label = vim.fn.strcharpart(label, 0, MAX_LABEL_WIDTH)
@ -103,7 +103,6 @@ return {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'cmdline' },
{ name = 'path' },
},
-- view = {
-- entries = { name = 'wildmenu', separator = ' · ' },
@ -141,3 +140,4 @@ return {
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done {})
end,
}

View File

@ -1,64 +0,0 @@
return {
'feline-nvim/feline.nvim',
-- lazy = false
-- event = 'UIEnter',
-- event = 'VeryLazy',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
config = function()
local feline = require 'feline'
local utils = require 'config.utils'
local c = utils.feline_c
local theme = utils.feline_theme
local vi_mode_colors = utils.feline_vi_mode_colors
local left = {
c.vim_mode,
c.file_info,
-- c.gitBranch,
-- c.gitDiffAdded,
-- c.gitDiffRemoved,
-- c.gitDiffChanged,
-- c.separator,
c.diagnostic_errors,
c.diagnostic_warnings,
c.diagnostic_info,
c.diagnostic_hints,
}
local middle = {
c.lsp_client_names,
c.separator,
}
local right = {
c.file_type,
c.search_count,
c.macro,
c.file_encoding,
c.position,
c.line_percentage,
c.scroll_bar,
}
local components = {
active = {
left,
middle,
right,
},
inactive = {
left,
middle,
right,
},
}
feline.setup {
components = components,
theme = theme,
vi_mode_colors = vi_mode_colors,
}
end,
}

View File

@ -1,12 +1,14 @@
return {
'folke/which-key.nvim',
'nvim-lua/plenary.nvim',
'mfussenegger/nvim-jdtls',
'simrat39/rust-tools.nvim',
'MunifTanjim/nui.nvim',
-- 'mfussenegger/nvim-jdtls',
-- 'simrat39/rust-tools.nvim',
-- 'MunifTanjim/nui.nvim',
{'rush-rs/tree-sitter-asm', ft = 'asm'},
{ 'jghauser/mkdir.nvim', lazy = false },
{
url = 'https://dev.filnar.com/fiplox/neogruber.nvim',
-- url = 'https://dev.filnar.com/fiplox/neogruber.nvim',
dir = '~/dev/neogruber.nvim/',
lazy = false,
-- event = 'VeryLazy'
},
@ -16,7 +18,7 @@ return {
keys = { { 's', ':HopChar2<cr>' }, { 'S', ':HopWord<cr>' } },
config = true,
},
{
--[[ {
'stevearc/dressing.nvim',
lazy = true,
init = function()
@ -34,8 +36,8 @@ return {
trim_prompt = false,
},
},
},
{
},]]
--[[ {
'folke/noice.nvim',
opts = {
messages = {
@ -67,7 +69,7 @@ return {
},
},
},
},
},]]
{
'numToStr/Comment.nvim',
-- event = 'VeryLazy',
@ -256,8 +258,8 @@ return {
},
{
'stevearc/oil.nvim',
-- lazy = false,
event = 'Syntax',
lazy = false,
-- event = 'Syntax',
opts = {
-- Id is automatically added at the beginning, and name at the end
-- See :help oil-columns
@ -369,12 +371,19 @@ return {
},
},
},
{
{
'nvim-treesitter/nvim-treesitter',
-- lazy = false,
-- dependencies = { 'nvim-treesitter/playground' },
-- dependencies = 'windwp/nvim-ts-autotag',
config = function()
-- require('nvim-treesitter.parsers').get_parser_configs().asm = {
-- install_info = {
-- url = 'https://github.com/rush-rs/tree-sitter-asm.git',
-- files = { 'src/parser.c' },
-- branch = 'main',
-- },
-- }
local configs = require 'nvim-treesitter.configs'
configs.setup {
@ -386,7 +395,7 @@ return {
-- context_commentstring = { enable = true, config = { css = '// %s' } },
-- indent = {enable = true, disable = {"python", "html", "javascript"}},
-- TODO seems to be broken
indent = { enable = true, disable = { 'python', 'css' } },
indent = { enable = false, disable = { 'python', 'css' } },
-- autotag = { enable = true },
}
end,
@ -407,7 +416,8 @@ return {
fold_closed = '', -- icon used for closed folds
group = true, -- group results by file
padding = true, -- add an extra new line on top of the list
action_keys = { -- key mappings for actions in the trouble list
action_keys = {
-- key mappings for actions in the trouble list
-- map to {} to remove a mapping, for example:
-- close = {},
close = 'q', -- close the list
@ -449,7 +459,7 @@ return {
'j-morano/buffer_manager.nvim',
opts = {
-- line_keys = '', -- deactivate line keybindings
short_file_names = true,
short_file_names = false,
short_term_names = false,
select_menu_item_commands = {
edit = {

View File

@ -1,12 +1,40 @@
local M = {
'neovim/nvim-lspconfig',
name = 'lsp',
event = { 'BufRead *.lua,*.c,*.rust,*.go,*.py,*.java,*.cpp,*.h' , 'BufNewFile *.lua,*.c,*.rust,*.go,*.py,*.java,*.cpp,*.h' },
-- event = { 'BufRead *.lua,*.c,*.rust,*.go,*.py,*.java,*.cpp,*.h,*.asm,*.tex',
-- 'BufNewFile *.lua,*.c,*.rust,*.go,*.py,*.java,*.cpp,*.h,*,*.asm,*.tex' },
-- lazy = false,
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'williamboman/mason.nvim' },
}
local servers = { 'clangd', 'rust_analyzer', 'lua_ls', 'pyright', 'gopls', 'jdtls' }
local servers = { 'clangd', 'rust_analyzer', 'lua_ls', 'pyright', 'gopls', 'jdtls', 'asm_lsp', 'texlab' }
local function on_attach(client, bufnr)
--[[ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') ]]
if client.name == 'jdt.ls' then
client.server_capabilities.documentFormattingProvider = false
vim.lsp.codelens.refresh()
if JAVA_DAP_ACTIVE then
require('jdtls').setup_dap { hotcodereplace = 'auto' }
require('jdtls.dap').setup_dap_main_class_configs()
end
end
-- local ft = vim.api.nvim_buf_get_option(bufnr, 'filetype')
-- local has_formatter = require('null-ls.sources').get_available(ft, 'NULL_LS_FORMATTING') > 0
--
-- local enable = false
-- if has_formatter and not client.name == 'clangd' then
-- enable = client.name == 'null-ls'
-- else
-- enable = not (client.name == 'null-ls')
-- end
--
-- -- util.info(client.name .. " " .. (enable and "yes" or "no"), "format")
-- client.server_capabilities.documentFormattingProvider = enable
client.server_capabilities.documentFormattingProvider = true
-- client.server_capabilities.semanticTokensProvider = false
client.server_capabilities.semanticTokensProvider = nil
end
function M.config()
local utils = require 'config.utils'
@ -17,7 +45,7 @@ function M.config()
for _, server in ipairs(servers) do
opts = {
on_attach = utils.on_attach,
on_attach = on_attach,
capabilities = capabilities,
}

46
lua/plugins/lualine.lua Normal file
View File

@ -0,0 +1,46 @@
return {
'nvim-lualine/lualine.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
opts = {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'selectioncount', 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
}

View File

@ -1,58 +0,0 @@
return {
'jose-elias-alvarez/null-ls.nvim',
ft = 'markdown',
config = function()
local null_ls = require 'null-ls'
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
local formatting = null_ls.builtins.formatting
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
local diagnostics = null_ls.builtins.diagnostics
null_ls.setup {
debug = false,
sources = {
formatting.prettier.with { extra_args = { '--no-semi', '--single-quote', '--jsx-single-quote' } },
formatting.black.with { extra_args = { '--fast' } },
formatting.stylua.with { extra_args = { '--quote-style=AutoPreferSingle', '--call-parentheses=None' } },
-- formatting.clang_format.with {
-- filetypes = { 'c' },
-- extra_args = {
-- '--style',
-- '{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, AlwaysBreakAfterReturnType: AllDefinitions}',
-- -- '{AccessModifierOffset : -2, AllowShortIfStatementsOnASingleLine : Never, AlignConsecutiveMacros : true, AllowShortLoopsOnASingleLine : false, AlwaysBreakTemplateDeclarations : true, Standard : c++20, NamespaceIndentation : All, IndentWidth : 4, TabWidth : 4, BreakBeforeBraces : Linux, AllowShortFunctionsOnASingleLine : Empty, AllowShortBlocksOnASingleLine : Never, FixNamespaceComments : true, PointerAlignment : Right, ColumnLimit : 120, ContinuationIndentWidth : 2, UseTab : Always }',
-- },
-- },
formatting.clang_format.with {
filetypes = { 'cpp' },
extra_args = {
'--style',
'google',
},
},
formatting.beautysh,
formatting.goimports,
formatting.gofumpt,
formatting.sql_formatter,
diagnostics.golangci_lint.with {
extra_args = {
'-E',
'revive',
'-E',
'errcheck',
'-E',
'gosec',
'-E',
'nilerr',
'-E',
'nlreturn',
},
},
formatting.asmfmt.with {
filetypes = { 'asm', 's' },
},
-- diagnostics.flake8
},
}
end,
}