feat: move nvim.nix in common
This commit is contained in:
parent
fe5efac384
commit
fa6be53b31
5 changed files with 17 additions and 5 deletions
common
|
@ -1,4 +1,4 @@
|
|||
({ nixpkgs, ... }: {
|
||||
({ nixpkgs, home-manager, lib, ... }: {
|
||||
# Select internationalisation properties.
|
||||
i18n.defaultLocale = "en_CA.UTF-8";
|
||||
console = {
|
||||
|
@ -24,6 +24,18 @@
|
|||
};
|
||||
};
|
||||
|
||||
home-manager.users = let
|
||||
default = {
|
||||
imports = [
|
||||
./modules/neovim/nvim.nix
|
||||
];
|
||||
home.stateVersion = lib.mkDefault "23.05";
|
||||
};
|
||||
in {
|
||||
root = default;
|
||||
matt = default;
|
||||
};
|
||||
|
||||
imports = [
|
||||
./overlays/list.nix
|
||||
];
|
||||
|
|
51
common/modules/neovim/config/base.vim
Normal file
51
common/modules/neovim/config/base.vim
Normal file
|
@ -0,0 +1,51 @@
|
|||
" make tabs only 2 spaces
|
||||
set tabstop=2
|
||||
set shiftwidth=2
|
||||
set expandtab
|
||||
set smartindent
|
||||
|
||||
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>
|
||||
|
||||
" Minimap config
|
||||
let g:minimap_width = 6
|
||||
let g:minimap_auto_start = 1
|
||||
let g:minimap_auto_start_win_enter = 1
|
||||
let g:minimap_git_colors = 1
|
||||
|
||||
" Auto open Neo-Tree on big enough window
|
||||
function! OpenTree() abort
|
||||
if &columns > 100
|
||||
Neotree show
|
||||
Neotree close
|
||||
Neotree show
|
||||
endif
|
||||
endfunction
|
||||
|
||||
autocmd VimEnter * call OpenTree()
|
106
common/modules/neovim/config/config.lua
Normal file
106
common/modules/neovim/config/config.lua
Normal file
|
@ -0,0 +1,106 @@
|
|||
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 } }
|
||||
|
||||
-- Autoclose Minimap
|
||||
vim.api.nvim_create_autocmd('QuitPre', {
|
||||
pattern = '*',
|
||||
desc = 'Close minimap on exit',
|
||||
command = 'MinimapClose',
|
||||
})
|
118
common/modules/neovim/nvim.nix
Normal file
118
common/modules/neovim/nvim.nix
Normal file
|
@ -0,0 +1,118 @@
|
|||
# Home-manager module
|
||||
|
||||
{ pkgs, lib, ... }: let
|
||||
# installs a vim plugin from git with a given tag / branch
|
||||
plugin = owner: repo: rev: hash: pkgs.vimUtils.buildVimPlugin {
|
||||
pname = "${lib.strings.sanitizeDerivationName repo}";
|
||||
version = rev;
|
||||
src = pkgs.fetchFromGitHub {
|
||||
inherit rev owner repo hash;
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
{
|
||||
xdg.configFile = {
|
||||
"../.gradle/gradle.properties".source = pkgs.writeText "gradle.properties" ''
|
||||
org.gradle.java.home = ${pkgs.temurin-bin-17}
|
||||
'';
|
||||
};
|
||||
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
package = pkgs.neovim-nightly;
|
||||
|
||||
extraConfig = builtins.concatStringsSep "\n" [
|
||||
(lib.strings.fileContents ./config/base.vim)
|
||||
''
|
||||
lua << EOF
|
||||
${lib.strings.fileContents ./config/config.lua}
|
||||
EOF
|
||||
''
|
||||
];
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
tree-sitter
|
||||
nodejs_latest
|
||||
gradle
|
||||
bat
|
||||
|
||||
python311Packages.pylint
|
||||
nil
|
||||
];
|
||||
|
||||
coc = {
|
||||
enable = true;
|
||||
settings = {
|
||||
"colors.enable" = true;
|
||||
"coc.preferences.formatOnType" = true;
|
||||
"Lua.misc.parameters" = [
|
||||
"--metapath"
|
||||
"~/.cache/sumneko_lua/meta"
|
||||
"--logpath"
|
||||
"~/.cache/sumneko_lua/log"
|
||||
];
|
||||
"Lua.workspace.library" = [
|
||||
"$\{3rd\}/luv/library"
|
||||
];
|
||||
sumneko-lua = {
|
||||
serverDir = "${pkgs.lua-language-server}/share/lua-language-server";
|
||||
enableNvimLuaDev = true;
|
||||
};
|
||||
"java.jdt.ls.java.home" = "${pkgs.temurin-bin-17}";
|
||||
"bashIde.shellcheckPath" = "${pkgs.shellcheck}/bin/shellcheck";
|
||||
languageserver = {
|
||||
nix = {
|
||||
command = "nil";
|
||||
filetypes = [ "nix" ];
|
||||
rootPatterns = [ "flake.nix" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
vim-which-key
|
||||
|
||||
coc-java
|
||||
coc-css
|
||||
coc-sumneko-lua
|
||||
coc-highlight
|
||||
coc-json
|
||||
coc-pyright
|
||||
coc-sh
|
||||
coc-snippets
|
||||
coc-vimlsp
|
||||
coc-yaml
|
||||
coc-toml
|
||||
coc-markdownlint
|
||||
coc-tsserver
|
||||
neodev-nvim
|
||||
|
||||
coc-fzf
|
||||
fzfWrapper
|
||||
fzf-vim
|
||||
|
||||
nvim-treesitter.withAllGrammars
|
||||
nvim-treesitter
|
||||
nvim-autopairs
|
||||
|
||||
dracula-nvim
|
||||
(plugin "lukas-reineke"
|
||||
"indent-blankline.nvim"
|
||||
"0fe34b4c1b926e106d105d3ae88ef6cbf6743572"
|
||||
"sha256-e8gn4pJYALaQ6sGA66SFf8p6VLJBPxT/BimQhOd5eBs=")
|
||||
gitsigns-nvim
|
||||
lualine-nvim
|
||||
minimap-vim
|
||||
|
||||
neo-tree-nvim
|
||||
|
||||
# to explore more
|
||||
fugitive
|
||||
todo-comments-nvim
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue