diff --git a/hosts/macbook/configuration.nix b/hosts/macbook/configuration.nix index 2271605..9fe1075 100644 --- a/hosts/macbook/configuration.nix +++ b/hosts/macbook/configuration.nix @@ -33,6 +33,8 @@ environment.systemPackages = with pkgs; [ hello + man-pages + man-pages-posix ]; environment.variables = { diff --git a/hosts/macbook/home.nix b/hosts/macbook/home.nix index a8915b8..cfecff6 100644 --- a/hosts/macbook/home.nix +++ b/hosts/macbook/home.nix @@ -11,6 +11,7 @@ ../../modules/home-manager/zoxide ../../modules/home-manager/irssi ../../modules/home-manager/email + ../../modules/home-manager/zk ../../modules/home-manager/password-store ]; home.username = "mthomson"; @@ -19,7 +20,6 @@ home.sessionVariables = { EDITOR = "nvim"; - ZK_NOTEBOOK_DIR = "notes"; }; programs = { diff --git a/modules/home-manager/neovim/nvim/lua/plugins/lsp.lua b/modules/home-manager/neovim/nvim/lua/plugins/lsp.lua index 26ccc38..8e847c9 100644 --- a/modules/home-manager/neovim/nvim/lua/plugins/lsp.lua +++ b/modules/home-manager/neovim/nvim/lua/plugins/lsp.lua @@ -1,4 +1,14 @@ return { + { + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + { path = 'luvit-meta/library', words = { 'vim%.uv' } }, + }, + }, + }, + { 'Bilal2453/luvit-meta', lazy = true }, { 'neovim/nvim-lspconfig', cmd = 'LspInfo', @@ -25,26 +35,20 @@ return { end }) - vim.api.nvim_create_autocmd({ "VimEnter" }, { - callback = function() - local clients = vim.lsp.get_clients() - for _, client in ipairs(clients) do - local id = client.id - vim.lsp.completion.enable(true, id, 1, { autotrigger = true }) - return - end - end, - }) + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) -- Server configs local lsp = require('lspconfig') -- vue lsp.volar.setup({ + capabilities = capabilities, }) -- typescript / javascript require'lspconfig'.ts_ls.setup{ + capabilities = capabilities, init_options = { plugins = { { @@ -59,37 +63,126 @@ return { -- eslint lsp.eslint.setup({ + capabilities = capabilities, }) -- tailwind lsp.tailwindcss.setup({ + capabilities = capabilities, root_dir = lsp.util.root_pattern('tailwind.config.js', 'tailwind.config.cjs', 'tailwind.config.mjs', 'tailwind.config.ts') }) -- html lsp.html.setup({ + capabilities = capabilities, }) -- go lsp.gopls.setup({ - settings = { - gopls = { - completeFunctionCalls = false, - } - } + capabilities = capabilities, }) lsp.golangci_lint_ls.setup({ + capabilities = capabilities, }) -- templ vim.filetype.add({ extension = { templ = "templ" } }) - lsp.templ.setup({}) + lsp.templ.setup({ + capabilities = capabilities, + }) - lsp.lua_ls.setup({}) + lsp.lua_ls.setup({ + capabilities = capabilities, + }) - lsp.nil_ls.setup({}) - lsp.ccls.setup({}) - lsp.astro.setup({}) + lsp.nil_ls.setup({ + capabilities = capabilities, + }) + + lsp.ccls.setup({ + capabilities = capabilities, + }) + lsp.astro.setup({ + capabilities = capabilities, + }) + lsp.cssls.setup({ + capabilities = capabilities, + }) end, }, + { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + { + 'L3MON4D3/LuaSnip', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, + }, + }, + 'saadparwaiz1/cmp_luasnip', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + }, + config = function() + -- See `:help cmp` + local cmp = require 'cmp' + local luasnip = require 'luasnip' + luasnip.config.setup {} + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = 'menu,menuone,noinsert' }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { 'i', 's' }), + }, + sources = { + { + name = 'lazydev', + -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it + group_index = 0, + }, + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + }, + } + end, + }, + { + 'nvim-tree/nvim-web-devicons', + } } diff --git a/modules/home-manager/neovim/nvim/lua/plugins/mini.lua b/modules/home-manager/neovim/nvim/lua/plugins/mini.lua index 19e608c..0cb45c4 100644 --- a/modules/home-manager/neovim/nvim/lua/plugins/mini.lua +++ b/modules/home-manager/neovim/nvim/lua/plugins/mini.lua @@ -75,7 +75,7 @@ return { -- Collection of various small independent plugins/modules keymap("n", "fg", pick.builtin.grep_live, { noremap = true, silent = true }) keymap("n", "fwg", function() local wrd = vim.fn.expand("") - pick.builtin.grep_live({ pattern = wrd }) + pick.builtin.grep({ pattern = wrd }) end, { noremap = true, silent = true }) -- require('mini.base16').setup({ @@ -107,8 +107,6 @@ return { -- Collection of various small independent plugins/modules -- saturation = 'high' -- }) - require('mini.completion').setup() - require('mini.splitjoin').setup() require('mini.trailspace').setup() diff --git a/modules/home-manager/neovim/nvim/lua/plugins/zk.lua b/modules/home-manager/neovim/nvim/lua/plugins/zk.lua new file mode 100644 index 0000000..bd10bee --- /dev/null +++ b/modules/home-manager/neovim/nvim/lua/plugins/zk.lua @@ -0,0 +1,23 @@ +return { + "zk-org/zk-nvim", + config = function() + require("zk").setup({ + picker = "minipick", + }) + local opts = { noremap=true, silent=false } + + -- Create a new note after asking for its title. + vim.api.nvim_set_keymap("n", "zn", "ZkNew { title = vim.fn.input('Title: ') }", opts) + vim.api.nvim_set_keymap("n", "zd", "ZkNew { dir = \"journal/daily\" }", opts) + + -- Open notes. + vim.api.nvim_set_keymap("n", "zo", "ZkNotes { sort = { 'modified' } }", opts) + -- Open notes associated with the selected tags. + vim.api.nvim_set_keymap("n", "zt", "ZkTags", opts) + + -- Search for the notes matching a given query. + vim.api.nvim_set_keymap("n", "zf", "ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }", opts) + -- Search for the notes matching the current visual selection. + vim.api.nvim_set_keymap("v", "zf", ":'<,'>ZkMatch", opts) + end +} diff --git a/modules/home-manager/zk/default.nix b/modules/home-manager/zk/default.nix new file mode 100644 index 0000000..f20e097 --- /dev/null +++ b/modules/home-manager/zk/default.nix @@ -0,0 +1,30 @@ +{ pkgs, config, ... }: + +{ + programs = { + zk = { + enable = true; + settings = { + notebook = { + dir = "~/notes"; + }; + extra = { + author = "Michael Thomson"; + }; + alias = { + daily = "zk new --no-input \"$ZK_NOTEBOOK_DIR/journal/daily\""; + }; + group = { + daily = { + paths = ["journal/daily"]; + note = { + filename = "{{format-date now '%Y-%m-%d'}}"; + extension = "md"; + template = "daily.md"; + }; + }; + }; + }; + }; + }; +} diff --git a/modules/home-manager/zsh/default.nix b/modules/home-manager/zsh/default.nix index c67956f..4c2d63d 100644 --- a/modules/home-manager/zsh/default.nix +++ b/modules/home-manager/zsh/default.nix @@ -1,6 +1,11 @@ { pkgs, config, ... }: { + + home.sessionVariables = { + ZK_NOTEBOOK_DIR = "\${HOME}/notes"; + }; + programs = { zsh = { enable = true;