summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2022-11-11 17:46:12 +0100
committerMike Vink <mike1994vink@gmail.com>2022-11-11 17:46:12 +0100
commit70f3bc54f2ba254645b0f7d4676443e034456d7a (patch)
tree8accaaf324d3ddd12967ff1d0fefc88244e49f16
parent91fb3eff2cf2cdc16a0bef278cd7fb64cde796b8 (diff)
feat(flake): no more hardcoding!
-rw-r--r--flake.nix122
-rw-r--r--home.nix199
-rw-r--r--neovim/init.lua23
-rw-r--r--neovim/lua/vimrc.lua49
-rw-r--r--neovim/lua/vimrc/lsp.lua232
5 files changed, 294 insertions, 331 deletions
diff --git a/flake.nix b/flake.nix
index 8409d0f..3ca0fbc 100644
--- a/flake.nix
+++ b/flake.nix
@@ -11,55 +11,85 @@
};
};
- outputs = { self, nixpkgs, nixpkgs-stable, home-manager, ... }:
- let
- system = "x86_64-linux";
- overlay = nixpkgs.lib.composeManyExtensions [
- (final: prev: {
- vimPlugins = prev.vimPlugins // {
- nvim-treesitter = prev.vimPlugins.nvim-treesitter.overrideAttrs (old: {
- version = "2022-10-28";
- src = builtins.fetchGit {
- url = "file:///home/mike/projects/nvim-treesitter";
- rev = "2c0ae6e8e81366ba088f1e5be62f467212cda52e";
- };
- passthru.withPlugins =
- grammarFn: final.vimPlugins.nvim-treesitter.overrideAttrs (_: {
- postPatch =
- let
- grammars = prev.tree-sitter.withPlugins grammarFn;
- in
- ''
- rm -r parser
- ln -s ${grammars} parser
- '';
- });
- });
- };
- })
- ];
+ outputs = {
+ self,
+ nixpkgs,
+ nixpkgs-stable,
+ home-manager,
+ ...
+ }: let
+ system = "x86_64-linux";
+ overlay = nixpkgs.lib.composeManyExtensions [
+ (final: prev: {
+ vimPlugins =
+ prev.vimPlugins
+ // {
+ nvim-treesitter = prev.vimPlugins.nvim-treesitter.overrideAttrs (old: {
+ version = "2022-10-28";
+ src = builtins.fetchGit {
+ url = "file:///home/mike/projects/nvim-treesitter";
+ rev = "2c0ae6e8e81366ba088f1e5be62f467212cda52e";
+ };
+ passthru.withPlugins = grammarFn:
+ final.vimPlugins.nvim-treesitter.overrideAttrs (_: {
+ postPatch = let
+ grammars = prev.tree-sitter.withPlugins grammarFn;
+ in ''
+ rm -r parser
+ ln -s ${grammars} parser
+ '';
+ });
+ });
+ };
+ })
- pkgs = import nixpkgs {
- overlays = [
- overlay
- ];
- inherit system;
- };
- in {
+ # fetchPluginFromGit = name: rev: pkgs.vimUtils.buildVimPluginFrom2Nix {
+ # name = name;
+ # src = builtins.fetchGit {
+ # url = "https://github.com/${name}";
+ # submodules = true;
+ # inherit rev;
+ # };
+ # };
+
+ # (fetchPluginFromGit "klen/nvim-test" "32f162c27045fc712664b9ddbd33d3c550cb2bfc")
+
+ (final: prev: {
+ vimPlugins =
+ prev.vimPlugins
+ // {
+ firvish-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
+ name = "firvish-nvim";
+ src = builtins.fetchGit {
+ url = "https://github.com/Furkanzmc/firvish.nvim";
+ submodules = true;
+ rev = "127f9146175d6bbaff6a8b761081cfd2279f8351";
+ };
+ };
+ };
+ })
+ ];
- homeConfigurations.mike = home-manager.lib.homeManagerConfiguration {
- pkgs = pkgs;
- # Specify your home configuration modules here, for example,
- # the path to your home.nix.
- modules = [
- ./home.nix
- ];
+ pkgs = import nixpkgs {
+ overlays = [
+ overlay
+ ];
+ inherit system;
+ };
+ in {
+ homeConfigurations.mike = home-manager.lib.homeManagerConfiguration {
+ inherit pkgs;
+ # Specify your home configuration modules here, for example,
+ # the path to your home.nix.
+ modules = [
+ ./home.nix
+ ];
- # Optionally use extraSpecialArgs
- # to pass through arguments to home.nix
- extraSpecialArgs = {
- flake = self;
- };
+ # Optionally use extraSpecialArgs
+ # to pass through arguments to home.nix
+ extraSpecialArgs = {
+ flake = self;
};
};
+ };
}
diff --git a/home.nix b/home.nix
index cde7d32..a906017 100644
--- a/home.nix
+++ b/home.nix
@@ -1,112 +1,127 @@
-{ flake, config, pkgs, ... }:
-
{
- # Found this here: nix-community.github.io configuration example
+ flake,
+ config,
+ pkgs,
+ ...
+}: {
+ # Found this here: nix-community.github.io configuration example
- home.username = "mike";
- home.homeDirectory = "/home/mike";
- home.stateVersion = "22.05";
- programs.home-manager.enable = true;
-
- home.packages = with pkgs; [
- htop
- fortune
- vim
- docker
- stow
- (nerdfonts.override { fonts = [ "FiraCode" ]; })
+ home.username = "mike";
+ home.homeDirectory = "/home/mike";
+ home.stateVersion = "22.05";
+ programs.home-manager.enable = true;
- firefox-wayland
+ home.packages = with pkgs; [
+ htop
+ fortune
+ vim
+ docker
+ stow
+ (nerdfonts.override {fonts = ["FiraCode"];})
+ ripgrep
- swaylock
- swayidle
- wl-clipboard
- mako
- wofi
- waybar
- ];
+ firefox-wayland
- programs.git = {
- enable = true;
- userName = "Mike Vink";
- userEmail = "mike1994vink@gmail.com";
- };
+ swaylock
+ swayidle
+ wl-clipboard
+ mako
+ wofi
+ waybar
+ ];
- programs.alacritty = {
- enable = true;
- settings = {
- env.TERM = "alacritty";
- font = {
- normal = {
- family = "FiraCode Nerd Font";
- style = "Regular";
- };
+ programs.git = {
+ enable = true;
+ userName = "Mike Vink";
+ userEmail = "mike1994vink@gmail.com";
+ };
+
+ programs.alacritty = {
+ enable = true;
+ settings = {
+ env.TERM = "alacritty";
+ font = {
+ normal = {
+ family = "FiraCode Nerd Font";
+ style = "Regular";
};
};
};
+ };
- wayland.windowManager.sway = {
- enable = true;
- wrapperFeatures.gtk = true;
- config = rec {
- terminal = "alacritty";
- menu = "wofi --show run";
- modifier = "Mod4";
- bars = [{
- fonts.size = 15.0;
- position = "bottom";
- }];
- startup = [
- {command = "firefox";}
- ];
- };
+ wayland.windowManager.sway = {
+ enable = true;
+ wrapperFeatures.gtk = true;
+ config = rec {
+ terminal = "alacritty";
+ menu = "wofi --show run";
+ modifier = "Mod4";
+ bars = [
+ {
+ fonts.size = 15.0;
+ position = "bottom";
+ }
+ ];
+ startup = [
+ {command = "firefox";}
+ ];
};
-
- # netrc-file = ~/.netrc;
+ };
- programs.neovim = {
- enable = true;
- package = pkgs.neovim-unwrapped;
- viAlias = true;
- vimAlias = true;
- extraConfig = "
+ programs.neovim = {
+ enable = true;
+ package = pkgs.neovim-unwrapped;
+ viAlias = true;
+ vimAlias = true;
+ extraPackages = with pkgs; [
+ sumneko-lua-language-server
+ pyright
+ gopls
+ yaml-language-server
+ alejandra
+ statix
+ ];
+ extraConfig = "
lua <<LUA
+Flake = {
+ lua_language_server = [[${pkgs.sumneko-lua-language-server}]],
+}
vim.opt.runtimepath:append({ [[${flake}/neovim]], [[${flake}/neovim/lua]] })
vim.cmd [[luafile ${flake}/neovim/init.lua]]
LUA
";
- plugins = with pkgs.vimPlugins;
- let
- fetchPluginFromGit = name: rev: pkgs.vimUtils.buildVimPluginFrom2Nix {
- name = name;
- src = builtins.fetchGit {
- url = "https://github.com/${name}";
- submodules = true;
- inherit rev;
- };
- };
- in [
- vim-nix
- vim-dirvish
- nvim-dap
- nvim-dap-ui
- vim-fugitive
- gruvbox-material
- luasnip
- nvim-lspconfig
- trouble-nvim
- nlua-nvim
- null-ls-nvim
- plenary-nvim
-
+ plugins = with pkgs.vimPlugins; [
+ # highlighting
+ (nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars))
+ playground
+ gruvbox-material
- (nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars))
- playground
+ # external
+ vim-dirvish
+ vim-fugitive
+ vim-oscyank
+ firvish-nvim
- (fetchPluginFromGit "klen/nvim-test" "32f162c27045fc712664b9ddbd33d3c550cb2bfc")
- (fetchPluginFromGit "mvinkio/tnychain" "cef72f688e67f40616db8ecf9d7c63e505c2dd23")
- (fetchPluginFromGit "Furkanzmc/firvish.nvim" "127f9146175d6bbaff6a8b761081cfd2279f8351")
- (fetchPluginFromGit "ray-x/lsp_signature.nvim" "137bfaa7c112cb058f8e999a8fb49363fae3a697")
- ];
- };
+ # moving around
+ marks-nvim
+
+ # Coding
+ nvim-lspconfig
+ nvim-dap
+ nvim-dap-ui
+ luasnip
+ trouble-nvim
+ null-ls-nvim
+ plenary-nvim
+ nlua-nvim
+ lsp_signature-nvim
+
+ # cmp
+ nvim-cmp
+ cmp-nvim-lsp
+ cmp-buffer
+ cmp-path
+ cmp_luasnip
+ ];
+ };
}
diff --git a/neovim/init.lua b/neovim/init.lua
index c036f59..c3294ed 100644
--- a/neovim/init.lua
+++ b/neovim/init.lua
@@ -115,14 +115,9 @@ vim.cmd([[command! -bang Gap :G commit -am 'fixmeuplater' | G push]])
vim.api.nvim_set_keymap('n', ']p', ':tabn<cr>', { silent = true, noremap = true})
vim.api.nvim_set_keymap('n', '[p', ':tabp<cr>', { silent = true, noremap = true})
-require'tnychain'.setup(
- {
- complete_key = '<c-n>',
- repeat_chain = '<c-p>'
- }
-)
+require'vimrc'.setup_cmp()
--- require'vimrc.snippets'.setup()
+require'vimrc.snippets'.setup()
-- }}}
@@ -221,13 +216,13 @@ require"trouble".setup { }
-- }}}
-- {{{ tests
-require"nvim-test".setup{}
-vim.api.nvim_set_keymap(
- "n",
- "<leader>t",
- "<cmd>TestFile<CR>",
- {silent = true, noremap = true}
-)
+-- require"nvim-test".setup{}
+-- vim.api.nvim_set_keymap(
+-- "n",
+-- "<leader>t",
+-- "<cmd>TestFile<CR>",
+-- {silent = true, noremap = true}
+-- )
-- }}}
-- lsp {{{
diff --git a/neovim/lua/vimrc.lua b/neovim/lua/vimrc.lua
index 587f9e2..817ec92 100644
--- a/neovim/lua/vimrc.lua
+++ b/neovim/lua/vimrc.lua
@@ -11,6 +11,37 @@ augroup end
]])
end
+function M.setup_cmp()
+ local cmp = require 'cmp'
+ cmp.setup({
+ snippet = {
+ -- REQUIRED - you must specify a snippet engine
+ expand = function(args)
+ require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
+ end,
+ },
+ completion = {
+ autocomplete = false
+ },
+ window = {
+ -- completion = cmp.config.window.bordered(),
+ -- documentation = cmp.config.window.bordered(),
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-A>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.abort(),
+ ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
+ }),
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ { name = 'luasnip' },
+ { name = 'path' },
+ })
+ })
+end
+
function M.setup_treesitter()
if vim.o.loadplugins == false then
return
@@ -34,6 +65,7 @@ function M.setup_treesitter()
},
indent = {
enable = true,
+ disable = { "python", "yaml" },
},
}
vim.cmd [[hi link TSParameter Todo]]
@@ -120,12 +152,13 @@ function M.setup_build_function()
local pipeline = os.getenv('AZURE_YAML_DEFINITION_ID')
local branch = os.getenv('AZURE_YAML_BRANCH')
- local url = [[https://dev.azure.com/]] .. ado_org .. [[/]] .. ado_proj .. [[/_apis/pipelines/]] .. pipeline .. [[/preview?api-version=7.1-preview.1]]
+ local url = [[https://dev.azure.com/]] ..
+ ado_org .. [[/]] .. ado_proj .. [[/_apis/pipelines/]] .. pipeline .. [[/preview?api-version=7.1-preview.1]]
local auth_header = [[Authorization: Basic ]] .. auth
local yaml_file = cwd .. "/" .. file
local shell_script = string.format(
-[[yaml_string="
+ [[yaml_string="
$(cat ${PWD}/${AZURE_YAML_DEBUG_SNIPPET})
$(cat %s)
"
@@ -143,7 +176,7 @@ curl -s -X POST '%s' -H 'Content-Type: application/json' -H '%s' --data-binary @
},
"yamlOverride":"$yaml_string"
}
-THEEND]],
+THEEND]] ,
yaml_file, url, auth_header, branch, branch
)
local cmd = {
@@ -175,15 +208,15 @@ M.reload_package_complete = function(_, _, _)
end
M.reload_packages_and_init = function()
- for name,_ in pairs(package.loaded) do
+ for name, _ in pairs(package.loaded) do
if name:match('^vimrc') then
package.loaded[name] = nil
end
end
-
- vim.opt.runtimepath:prepend({ os.getenv("NVIM_RELOAD_PATH"), os.getenv("NVIM_RELOAD_PATH") .. [[/lua]] })
- dofile(os.getenv("NVIM_RELOAD_PATH") .. [[/init.lua]])
- vim.opt.runtimepath:remove({ os.getenv("NVIM_RELOAD_PATH"), os.getenv("NVIM_RELOAD_PATH") .. [[/lua]] })
+ local reload_path = os.getenv("NVIM_RELOAD_PATH") or [[/home/mike/dotnix/neovim]]
+ vim.opt.runtimepath:prepend({ reload_path, reload_path .. [[/lua]] })
+ dofile(reload_path .. [[/init.lua]])
+ vim.opt.runtimepath:remove({ reload_path, reload_path .. [[/lua]] })
vim.notify("Reloaded vim", vim.log.levels.INFO)
end
diff --git a/neovim/lua/vimrc/lsp.lua b/neovim/lua/vimrc/lsp.lua
index 94a2cc2..8b23fc6 100644
--- a/neovim/lua/vimrc/lsp.lua
+++ b/neovim/lua/vimrc/lsp.lua
@@ -123,195 +123,85 @@ function M.setup()
end
local buffer_setup_no_format = function(client)
- client.server_capabilities.document_formatting = false
buffer_setup(client)
end
-- lspconfig {{{
- local lspconfig = require 'lspconfig'
- -- check if docker is executable first?
- local runtime_path = vim.split(package.path, ';')
- table.insert(runtime_path, "lua/?.lua")
- table.insert(runtime_path, "lua/?/init.lua")
+ local lspconfig = require('lspconfig')
+ local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- always load lua lsp
- require('nlua.lsp.nvim').setup(require('lspconfig'), {
- cmd = { "/lsp/bin/lua-language-server", "-E", "/lsp/main.lua" },
- on_attach = buffer_setup_no_format,
-
- -- Include globals you want to tell the LSP are real :)
- globals = {
- -- Colorbuddy
- "Color", "c", "Group", "g", "s",
- }
+ require('nlua.lsp.nvim').setup(lspconfig, {
+ cmd = {
+ Flake.lua_language_server .. "/bin/lua-language-server",
+ "-E", Flake.lua_language_server .. "/share/lua-language-server/main.lua"
+ },
+ capabilities = capabilities,
+ on_attach = buffer_setup_no_format,
+
+ -- Include globals you want to tell the LSP are real :)
+ globals = {
+ -- Colorbuddy
+ "Color", "c", "Group", "g", "s", "Flake",
+ }
})
- -- lspconfig.sumneko_lua.setup {
- -- filetypes = { "lua" },
- -- on_attach = buffer_setup_no_format,
- -- settings = {
- -- Lua = {
- -- completion = {
- -- keywordSnippet = "Disable",
- -- showWord = "Disable",
- -- },
- -- diagnostics = {
- -- enable = true,
- -- globals = vim.list_extend({
- -- -- Neovim
- -- "vim",
- -- -- Busted
- -- "describe", "it", "before_each", "after_each", "teardown", "pending", "clear"
- -- }, {})
- -- },
- -- runtime = {
- -- version = "LuaJIT",
- -- },
- -- workspace = {
- -- vim.list_extend(get_lua_runtime(), {}),
- -- maxPreload = 10000,
- -- preloadFileSize = 10000,
- -- },
- -- }
- -- }
- -- }
-
- -- out = vim.fn.system('docker images -q mvinkio/azure-pipelines-lsp')
- -- if string.len(out) ~= 0 then
- -- lspconfig.yamlls.setup {
- -- before_init = function(params)
- -- params.processId = vim.NIL
- -- end,
- -- on_new_config = function(new_config, new_root_dir)
- -- new_config.cmd = {
- -- "node",
- -- new_root_dir,
- -- home .. "/projects/devops-pipelines/node_modules/azure-pipelines-language-server/out/server.js",
- -- "--stdio"
- -- }
- -- end,
- -- filetypes = { "yaml" },
- -- root_dir = lspconfig.util.root_pattern(".git", vim.fn.getcwd()),
- -- on_attach = buffer_setup_no_format,
- -- settings = {
- -- yaml = {
- -- format = {
- -- enable = true
- -- },
- -- schemas = {
- -- [home .. "/projects/devops-pipelines/schema"] = "/*"
- -- },
- -- validate = true
- -- }
- -- }
- -- }
- -- else
- -- utils.log_warning("No image mvinkio/azure-pipelines-lsp.", "vimrc/lsp", true)
- -- end
-
- local out = vim.fn.system('docker images -q mvinkio/python')
- if string.len(out) ~= 0 then
- lspconfig.pyright.setup {
- cmd = {
- "docker",
- "run",
- "--rm",
- "--env-file=" .. vim.fn.getcwd() .. "/.env",
- "--interactive",
- "--workdir=" .. vim.fn.getcwd(),
- "--volume=" .. vim.fn.getcwd() .. ":" .. vim.fn.getcwd(),
- "mvinkio/python",
- "pyright-langserver", "--stdio"
+ lspconfig.pyright.setup {
+ root_dir = lspconfig.util.root_pattern(".git", vim.fn.getcwd()),
+ on_attach = buffer_setup_no_format,
+ }
+
+ lspconfig.gopls.setup {
+ before_init = function(params)
+ params.processId = vim.NIL
+ end,
+ capabilities = capabilities,
+ filetypes = { "go", "gomod", "gotmpl" },
+ on_attach = buffer_setup_no_format,
+ settings = {
+ gopls = {
+ experimentalPostfixCompletions = true,
+ analyses = {
+ unusedparams = true,
+ shadow = true,
+ },
+ staticcheck = true,
},
- on_new_config = function(new_config, new_root_dir)
- new_config.cmd = {
- "docker",
- "run",
- "--rm",
- "--env-file=" .. new_root_dir .. "/.env",
- "--interactive",
- "--workdir=" .. new_root_dir,
- "--volume=" .. new_root_dir .. ":" .. new_root_dir,
- "mvinkio/python",
- "pyright-langserver", "--stdio"
- }
- end,
- filetypes = { "python" },
- root_dir = lspconfig.util.root_pattern(".git", vim.fn.getcwd()),
- on_attach = buffer_setup_no_format,
- }
- else
- utils.log_warning("No image mvinkio/python.", "vimrc/lsp", true)
- end
-
- out = vim.fn.system('docker images -q mvinkio/go')
- if string.len(out) ~= 0 then
- lspconfig.gopls.setup {
- before_init = function(params)
- params.processId = vim.NIL
- end,
- on_new_config = function(new_config, new_root_dir)
- new_config.cmd = {
- "docker",
- "run",
- "--rm",
- "--interactive",
- "-e=GOPROXY=https://proxy.golang.org",
- "-e=GOOS=linux",
- "-e=GOARCH=amd64",
- "-e=GOPATH=" .. new_root_dir .. "/go",
- "-e=GOCACHE=" .. new_root_dir .. "/.cache/go-build",
- "--workdir=" .. new_root_dir,
- "--volume=" .. new_root_dir .. ":" .. new_root_dir,
- "--network=bridge",
- "mvinkio/go",
- "gopls"
- }
- end,
- -- cmd = { "docker", "run", "--rm", "-i", "-v", home .. ":" .. home, "mvinkio/gopls" },
- filetypes = { "go", "gomod", "gotmpl" },
- on_attach = buffer_setup_no_format,
+ },
+ init_options = {
+ usePlaceholders = true,
}
- else
- utils.log_warning("No image mvinkio/go.", "vimrc/lsp", true)
- end
-
- -- out = vim.fn.system('docker images -q mvinkio/sveltels')
- -- if string.len(out) ~= 0 then
- -- lspconfig.svelte.setup {
- -- before_init = function(params)
- -- params.processId = vim.NIL
- -- end,
- -- cmd = {
- -- "docker",
- -- "run",
- -- "--rm",
- -- "--interactive",
- -- "--volume=" .. home .. ":" .. home,
- -- "--network=none",
- -- "mvinkio/sveltels"
- -- },
- -- on_attach = buffer_setup,
- -- }
- -- else
- -- utils.log_warning("No image mvinkio/sveltels.", "vimrc/lsp", true)
- -- end
-
+ }
+
+ lspconfig.yamlls.setup {
+ schemas = {
+ ["https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.18.0-standalone-strict/all.json"] = "/*.k8s.yaml",
+ },
+ capabilities = capabilities,
+ on_attach = function(client)
+ buffer_setup_no_format(client)
+ local bufnr = vim.api.nvim_get_current_buf()
+ if vim.bo[bufnr].buftype ~= ""
+ or vim.bo[bufnr].filetype == "helm" then
+ vim.diagnostic.disable(bufnr)
+ vim.defer_fn(function()
+ vim.diagnostic.reset(nil, bufnr)
+ end, 1000)
+ end
+ end,
+ }
-- }}}
local null_ls = require("null-ls")
- local my_black = null_ls.builtins.formatting.black.with({
- filetypes = { "python" },
- command = "black",
- args = { "$FILENAME" }
- })
null_ls.setup({
debug = vim.fn.expand("$VIMRC_NULL_LS_DEBUG") == "1",
update_on_insert = false,
on_attach = buffer_setup,
sources = {
- my_black,
- null_ls.builtins.completion.luasnip
+ -- nix linter: statix
+ null_ls.builtins.code_actions.statix,
+ null_ls.builtins.diagnostics.statix,
+ null_ls.builtins.formatting.alejandra,
}
})
end