refactor(nvim): organise configs by plugin and some other stuff

This commit is contained in:
matt1432 2023-10-27 01:15:33 -04:00
parent 72ba6d1e4a
commit 02fe021715
13 changed files with 256 additions and 215 deletions

View file

@ -0,0 +1,26 @@
" by default, the indent is 2 spaces.
set smartindent
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
" for html/rb files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
autocmd Filetype ruby setlocal ts=2 sw=2 expandtab
" for js/coffee/jade files, 4 spaces
autocmd Filetype javascript setlocal ts=4 sw=4 sts=0 expandtab
autocmd Filetype java setlocal ts=4 sw=4 sts=0 expandtab
" support scss @
autocmd FileType scss setl iskeyword+=@-@
set number
set relativenumber
set undofile
set undodir=/home/matt/.cache/nvim/
" remove highlight on words
nnoremap <silent> <esc> :noh<cr><esc>

View file

@ -1,55 +0,0 @@
" by default, the indent is 2 spaces.
set smartindent
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
" for html/rb files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
autocmd Filetype ruby setlocal ts=2 sw=2 expandtab
" for js/coffee/jade files, 4 spaces
autocmd Filetype javascript setlocal ts=4 sw=4 sts=0 expandtab
autocmd Filetype java setlocal ts=4 sw=4 sts=0 expandtab
set number
set relativenumber
set undofile
set undodir=/home/matt/.cache/nvim/
" set dot icon in place of trailing whitespaces
set list listchars=tab:\ \ ,nbsp:␣,trail:•,extends:⟩,precedes:⟨
" use vscode keybinds for snippets completion
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ CheckBackspace() ? "\<TAB>" :
\ coc#refresh()
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'
" support scss @
autocmd FileType scss setl iskeyword+=@-@
" remove highlight on words
nnoremap <silent> <esc> :noh<cr><esc>
" Auto open Neo-Tree on big enough window
function! OpenTree() abort
if &columns > 100
Neotree show
Neotree close
Neotree show
endif
lua MiniMap.open()
endfunction
autocmd VimEnter * call OpenTree()

View file

@ -1,111 +0,0 @@
vim.opt.fillchars = {eob = " "}
vim.cmd[[colorscheme dracula]]
-- https://github.com/AstroNvim/AstroNvim/issues/648#issuecomment-1511728897
vim.g.loaded_netrw = 0
vim.g.loaded_netrwPlugin = 0
-- https://github.com/nvim-neo-tree/neo-tree.nvim/issues/983#issuecomment-1637372234
require'nvim-treesitter.configs'.setup {
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,
},
}
require('gitsigns').setup()
require('lualine').setup {
options = {
theme = 'dracula',
globalstatus = true
}
}
require("neo-tree").setup({
close_if_last_window = true,
enable_refresh_on_write = true,
window = {
width = 25,
},
filesystem = {
use_libuv_file_watcher = true,
filtered_items = {
visible = false,
hide_dotfiles = false,
hide_gitignored = true,
hide_by_name = {},
hide_by_pattern = {},
always_show = {},
never_show = {},
never_show_by_pattern = {},
},
},
source_selector = {
winbar = true,
statusline = false
},
follow_current_file = {
enabled = true,
leave_dirs_open = true,
}
})
require('todo-comments').setup()
-- Auto indent when pressing Enter between brackets
local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs')
npairs.setup({map_cr=false})
_G.MUtils= {}
MUtils.completion_confirm=function()
if vim.fn["coc#pum#visible"]() ~= 0 then
return vim.fn["coc#pum#confirm"]()
else
return npairs.autopairs_cr()
end
end
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})
-- Indent Blanklines
local highlight = {
"RainbowRed",
"RainbowYellow",
"RainbowBlue",
"RainbowOrange",
"RainbowGreen",
"RainbowViolet",
"RainbowCyan",
}
local hooks = require "ibl.hooks"
hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" })
vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" })
vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" })
vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
end)
require("ibl").setup { indent = { highlight = highlight } }
local map = require('mini.map')
map.setup({
integrations = {
map.gen_integration.builtin_search(),
map.gen_integration.gitsigns(),
map.gen_integration.diagnostic(),
},
window = {
width = 7,
},
})

View file

@ -9,11 +9,12 @@
inherit rev owner repo hash;
};
};
in
{
xdg.configFile = {
"../.gradle/gradle.properties".source = pkgs.writeText "gradle.properties" ''
fileContents = lib.strings.fileContents;
in {
# TODO: make a gradle module and have java in hostvars.nix
xdg.dataFile = {
".gradle/gradle.properties".source =
pkgs.writeText "gradle.properties" ''
org.gradle.java.home = ${pkgs.temurin-bin-17}
'';
};
@ -40,14 +41,6 @@ in
viAlias = true;
vimAlias = true;
extraConfig = with lib.strings; ''
${fileContents ./config/base.vim}
'';
extraLuaConfig = with lib.strings; ''
${fileContents ./config/config.lua}
'';
extraPackages = with pkgs; [
nodejs_latest
nodePackages.npm
@ -75,7 +68,7 @@ in
"eslint.format.enable" = true;
"eslint.autoFixOnSave" = true;
# Stylelint FIXME: not working
# Stylelint
"stylelintplus.enable" = true;
"stylelintplus.cssInJs" = true;
"stylelintplus.autoFixOnSave" = true;
@ -115,54 +108,98 @@ in
};
};
extraConfig = fileContents ./base.vim;
plugins = with pkgs.vimPlugins; [
vim-which-key
coc-java
# Coc configured
coc-css
coc-eslint
coc-java
coc-sh
coc-stylelintplus
{
plugin = coc-snippets;
type = "viml";
config = fileContents ./plugins/snippets.vim;
}
# Lua
## Lua
coc-sumneko-lua
neodev-nvim
## Fzf
coc-fzf
fzfWrapper
fzf-vim
coc-highlight
coc-json
coc-pyright
coc-sh
coc-snippets
coc-vimlsp
coc-yaml
coc-toml
coc-markdownlint
coc-tsserver
coc-eslint
coc-stylelintplus
coc-fzf
fzfWrapper
fzf-vim
nvim-treesitter
nvim-treesitter.withAllGrammars
nvim-autopairs
dracula-nvim
(plugin "lukas-reineke"
"indent-blankline.nvim"
"046e2cf04e08ece927bacbfb87c5b35c0b636546"
"sha256-bhoep8aTYje5K/dZ/XmpwBPn4PBEMPrmw33QJdfFe6M=")
gitsigns-nvim
lualine-nvim
(plugin "echasnovski"
"mini.map"
"75b7ca9443e17c852b24055b32f74a880cf48053"
"sha256-CoMc6yQXXAW1wzcD9eJGuM+kcOJghuwHjKrqEMxZBec=")
neo-tree-nvim
# to explore more
fugitive
todo-comments-nvim
{
plugin = dracula-nvim;
type = "viml";
config = fileContents ./plugins/dracula.vim;
}
{
plugin = lualine-nvim;
type = "lua";
config = fileContents ./plugins/lualine.lua;
}
{
plugin = todo-comments-nvim;
type = "lua";
config = "require('todo-comments').setup()";
}
{
plugin = gitsigns-nvim;
type = "lua";
config = "require('gitsigns').setup()";
}
{
plugin = nvim-autopairs;
type = "lua";
config = fileContents ./plugins/autopairs.lua;
}
{
plugin = nvim-treesitter-context;
}
{
plugin = nvim-treesitter.withAllGrammars;
type = "viml";
config = fileContents ./plugins/treesitter.vim;
}
{
plugin = (plugin "lukas-reineke" "indent-blankline.nvim"
"046e2cf04e08ece927bacbfb87c5b35c0b636546"
"sha256-bhoep8aTYje5K/dZ/XmpwBPn4PBEMPrmw33QJdfFe6M=");
type = "lua";
config = fileContents ./plugins/indent.lua;
}
{
plugin = (plugin "echasnovski" "mini.map"
"75b7ca9443e17c852b24055b32f74a880cf48053"
"sha256-CoMc6yQXXAW1wzcD9eJGuM+kcOJghuwHjKrqEMxZBec=");
type = "lua";
config = fileContents ./plugins/minimap.lua;
}
{
plugin = neo-tree-nvim;
type = "viml";
config = ''
${fileContents ./plugins/neotree.vim}
lua << EOF
${fileContents ./plugins/neotree.lua}
EOF
'';
}
];
};
};

View file

@ -0,0 +1,16 @@
-- Auto indent when pressing Enter between brackets
local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs')
npairs.setup({map_cr=false})
_G.MUtils= {}
MUtils.completion_confirm=function()
if vim.fn["coc#pum#visible"]() ~= 0 then
return vim.fn["coc#pum#confirm"]()
else
return npairs.autopairs_cr()
end
end
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})

View file

@ -0,0 +1,10 @@
" set dot icon in place of trailing whitespaces
set list listchars=tab:\ \ ,nbsp:␣,trail:•,extends:⟩,precedes:⟨
lua << EOF
-- Add visual indicator for trailing whitespaces
vim.opt.fillchars = {eob = " "}
vim.cmd[[colorscheme dracula]]
EOF

View file

@ -0,0 +1,21 @@
local highlight = {
"RainbowRed",
"RainbowYellow",
"RainbowBlue",
"RainbowOrange",
"RainbowGreen",
"RainbowViolet",
"RainbowCyan",
}
local hooks = require('ibl.hooks')
hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" })
vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" })
vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" })
vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
end)
require('ibl').setup({ indent = { highlight = highlight } })

View file

@ -0,0 +1,6 @@
require('lualine').setup({
options = {
theme = 'dracula',
globalstatus = true
}
})

View file

@ -0,0 +1,13 @@
local map = require('mini.map')
map.setup({
integrations = {
map.gen_integration.builtin_search(),
map.gen_integration.gitsigns(),
map.gen_integration.diagnostic(),
},
window = {
focusable = true,
width = 7,
winblend = 75,
},
})

View file

@ -0,0 +1,37 @@
-- Override netrw
vim.g.loaded_netrw = 0
vim.g.loaded_netrwPlugin = 0
require('neo-tree').setup({
close_if_last_window = true,
enable_refresh_on_write = true,
window = {
width = 22,
},
filesystem = {
use_libuv_file_watcher = true,
filtered_items = {
visible = false,
hide_dotfiles = false,
hide_gitignored = true,
hide_by_name = {},
hide_by_pattern = {},
always_show = {},
never_show = {},
never_show_by_pattern = {},
},
},
source_selector = {
winbar = true,
statusline = false
},
follow_current_file = {
enabled = true,
leave_dirs_open = true,
}
})

View file

@ -0,0 +1,11 @@
" Auto open Neo-Tree on big enough window
function! OpenTree() abort
if &columns > 100
Neotree show
Neotree close
Neotree show
endif
lua MiniMap.open()
endfunction
autocmd VimEnter * call OpenTree()

View file

@ -0,0 +1,13 @@
" use vscode keybinds for snippets completion
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ CheckBackspace() ? "\<TAB>" :
\ coc#refresh()
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'

View file

@ -0,0 +1,17 @@
lua << EOF
require('nvim-treesitter.configs').setup({
highlight = { enable = true },
indent = { enable = true }
})
require('treesitter-context').setup({
enable = true,
max_lines = 3,
min_window_height = 20,
})
EOF
" Add line under context
hi TreesitterContextBottom gui=underline guisp=Grey