diff --git a/.cspell.json b/.cspell.json new file mode 100644 index 0000000..324e8b2 --- /dev/null +++ b/.cspell.json @@ -0,0 +1,7 @@ +{ + "version": "0.2", + "language": "en-GB", + "words": [ "UKAEA" ], + "allowCompoundWords": true, + "useGitignore": true +} diff --git a/Makefile b/Makefile index dce636b..669852e 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,49 @@ BIN_DIR := $(HOME)/.local/bin FONTS_DIR := $(HOME)/.fonts -.PHONY: default clean nvim direnv firacode +.PHONY: default clean nvim firacode cspell -default: - command -v nvim > /dev/null || make nvim - command -v direnv > /dev/null || make direnv - -fc-list | grep -iE "(fira.*code)*(nerd.*font)" > /dev/null || make firacode +default: nvim firacode cspell clean: -rm -rf $(HOME)/.local/share/nvim -rm -rf $(HOME)/.local/state/nvim -rm -rf $(HOME)/.cache/nvim -rm $(BIN_DIR)/nvim - -rm $(BIN_DIR)/direnv -rm -rf $(FONTS_DIR)/FiraCode + -rm $(HOME)/.cspell.json nvim: $(BIN_DIR) - ./installers/nvim.sh + command -v nvim > /dev/null && exit 0 + curl -sSLO https://github.com/neovim/neovim/releases/download/stable/nvim.appimage + curl -sSLO https://github.com/neovim/neovim/releases/download/stable/nvim.appimage.sha256sum + sha256sum -c nvim.appimage.sha256sum || { + rm nvim.appimage nvim.appimage.sha256sum + exit 1 + } + rm nvim.appimage.sha256sum + chmod a+x nvim.appimage + mv nvim.appimage $(HOME)/.local/bin/nvim -direnv: $(BIN_DIR) - bin_path="$(BIN_DIR)" ./installers/direnv.sh +# direnv: $(BIN_DIR) +# bin_path="$(BIN_DIR)" ./installers/direnv.sh + +firacode: $(FONTS_DIR)/ firacode: $(FONTS_DIR) command -v fc-cache > /dev/null || exit 1 - ./installers/firacode.sh && fc-cache + command -v fc-list > /dev/null || exit 1 + fc-list | grep -iE "(fira.*code)*(nerd.*font)" > /dev/null && exit 0 + mkdir -p $(FONTS_DIR) && cd $(FONTS_DIR) + curl -sSLO https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.0/FiraCode.zip + unzip FiraCode.zip -d FiraCode + rm FiraCode.zip + fc-cache + +cspell: $(HOME)/.cspell.json + +$(HOME)/.cspell.json: + -ln -s $$(readlink -f .cspell.json) $@ $(BIN_DIR) $(FONTS_DIR): mkdir -p $@ diff --git a/installers/firacode.sh b/installers/firacode.sh index 74adaec..e69de29 100755 --- a/installers/firacode.sh +++ b/installers/firacode.sh @@ -1,6 +0,0 @@ -mkdir -p $HOME/.fonts -cd $HOME/.fonts -curl -sSLO https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.0/FiraCode.zip -unzip FiraCode.zip -d FiraCode -rm FiraCode.zip -fc-cache diff --git a/installers/nvim.sh b/installers/nvim.sh index 6ab9840..e69de29 100755 --- a/installers/nvim.sh +++ b/installers/nvim.sh @@ -1,9 +0,0 @@ -curl -sSLO https://github.com/neovim/neovim/releases/download/stable/nvim.appimage -curl -sSLO https://github.com/neovim/neovim/releases/download/stable/nvim.appimage.sha256sum -sha256sum -c nvim.appimage.sha256sum || { - rm nvim.appimage nvim.appimage.sha256sum - exit 1 -} -rm nvim.appimage.sha256sum -chmod a+x nvim.appimage -mv nvim.appimage $HOME/.local/bin/nvim diff --git a/lua/plugins/direnv.lua b/lua/plugins/direnv.lua index 2dd6616..c7b5895 100644 --- a/lua/plugins/direnv.lua +++ b/lua/plugins/direnv.lua @@ -1,6 +1,6 @@ return { "https://github.com/direnv/direnv.vim.git", - cond = not vim.g.vscode, + cond = function() return vim.fn.executable("direnv") == 1 and not vim.g.vscode end, name = "direnv.vim", event = { "DirChangedPre" }, config = function() diff --git a/lua/plugins/indent_blankline.lua b/lua/plugins/indent_blankline.lua index 59e0980..7be9df0 100644 --- a/lua/plugins/indent_blankline.lua +++ b/lua/plugins/indent_blankline.lua @@ -1,6 +1,7 @@ return { "lukas-reineke/indent-blankline.nvim", cond = not vim.g.vscode, + dependencies = {"nvim-treesitter"}, event = { "BufReadPre", "BufNewFile" }, config = true, opts = { diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index d402449..9f92370 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -44,34 +44,49 @@ local config = function() vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) end - local lsp_flags = { debounce_text_changes = 150 } - local capabilities = require("cmp_nvim_lsp").default_capabilities() - local servers = { - "pyright", - "ruff_lsp", - "nil_ls", - "lua_ls", - "fortls", - "yamlls", - "vimls", - "bashls", + local lsp_config = { + on_attach = on_attach, + flags = { debounce_text_changes = 150 }, + capabilities = require("cmp_nvim_lsp").default_capabilities(), } - for _, name in ipairs(servers) do - require("lspconfig")[name].setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, - } - end + local lsp = require("lspconfig") + if vim.fn.executable("pyright") == 1 then lsp["pyright"].setup(lsp_config) end + if vim.fn.executable("ruff_lsp") == 1 then lsp["ruff_lsp"].setup(lsp_config) end + if vim.fn.executable("lua-language-server") == 1 then lsp["lua_ls"].setup(lsp_config) end + if vim.fn.executable("fortls") == 1 then lsp["fortls"].setup(lsp_config) end + if vim.fn.executable("yamlls") == 1 then lsp["yamlls"].setup(lsp_config) end + if vim.fn.executable("vimls") == 1 then lsp["vimls"].setup(lsp_config) end + if vim.fn.executable("bashls") == 1 then lsp["bashls"].setup(lsp_config) end + -- local servers = { + -- {"pyright"}, + -- {"ruff_lsp"}, + -- {"nil_ls"}, + -- {"lua_langauge_server", "lua_ls"}, + -- {"fortls"}, + -- {"yamlls"}, + -- {"vimls"}, + -- {"bashls"}, + -- } + -- for _, name in ipairs(servers) do + -- if vim.fn.executable(name[0]) == 1 then + -- require("lspconfig")[name[1]].setup { + -- on_attach = on_attach, + -- flags = lsp_flags, + -- capabilities = capabilities, + -- } + -- end + -- end local builtins = require "null-ls.builtins" local cspell = require "cspell" - local cspell_filetypes = { "json", "yaml", "html", "markdown", "norg", "gitcommit" } - local cspell_config = { config_file_preferred_name = ".cspell.json" } + local cspell_config = { + filetypes = { "json", "yaml", "html", "markdown", "norg", "gitcommit" }, + config={ config_file_preferred_name = ".cspell.json" } + } require("null-ls").setup { sources = { - cspell.diagnostics.with { filetypes = cspell_filetypes, config = cspell_config }, - cspell.code_actions.with { filetypes = cspell_filetypes, config = cspell_config }, + cspell.diagnostics.with (cspell_config), + cspell.code_actions.with (cspell_config), builtins.code_actions.gitsigns, builtins.formatting.alejandra, @@ -84,9 +99,9 @@ local config = function() builtins.formatting.stylua, builtins.hover.dictionary, }, - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, + on_attach = lsp_config.on_attach, + flags = lsp_config.flags, + capabilities = lsp_config.capabilities, } end diff --git a/lua/plugins/nvim_neorg.lua b/lua/plugins/nvim_neorg.lua index 523bde8..d787179 100644 --- a/lua/plugins/nvim_neorg.lua +++ b/lua/plugins/nvim_neorg.lua @@ -5,7 +5,7 @@ return { ft = "norg", cmd = "Neorg", lazy = true, - dependencies = { "nvim-lua/plenary.nvim", "nvim-treesitter/nvim-treesitter" }, + dependencies = { "plenary.nvim", "nvim-treesitter", "nvim-cmp" }, init = function() vim.api.nvim_create_autocmd({ "BufWritePre" }, { pattern = { "*.norg" }, diff --git a/lua/plugins/project.lua b/lua/plugins/project.lua index 65a1134..5b5bc57 100644 --- a/lua/plugins/project.lua +++ b/lua/plugins/project.lua @@ -1,12 +1,11 @@ return { "ahmedkhalf/project.nvim", - cond = not vim.g.vscode, - enabled = false, + cond = not vim.g.neovide and not vim.g.vscode, name = "project_nvim", event = { "BufReadPre", "BufNewFile" }, config = true, opts = { - ignore_lsp = { "efm", "null-ls" }, + ignore_lsp = { "null-ls" }, show_hidden = true, silent_chdir = true, },