From 441844b0c569adf0499a9ae78b0c48c1e83fc66b Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 1 Feb 2022 16:18:36 +0200 Subject: [PATCH] feat: dashboard and stuff for nvim --- dotfiles/neovim/lua/my/plugins/init.lua | 1 + dotfiles/neovim/lua/my/plugins/lspconfig.lua | 79 +++++++++++--------- modules/applications/neovim.nix | 3 +- modules/dev/javascript.nix | 13 ++-- modules/overlays/npm.nix | 7 +- 5 files changed, 57 insertions(+), 46 deletions(-) diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua index 40da524..505b4d2 100644 --- a/dotfiles/neovim/lua/my/plugins/init.lua +++ b/dotfiles/neovim/lua/my/plugins/init.lua @@ -8,6 +8,7 @@ function M.setup() -- Other unconfigured plugins require('nvim-autopairs').setup() require('nvim_comment').setup() + require("startup").setup({theme = "dashboard"}) end return M diff --git a/dotfiles/neovim/lua/my/plugins/lspconfig.lua b/dotfiles/neovim/lua/my/plugins/lspconfig.lua index c512c8b..e9378d8 100644 --- a/dotfiles/neovim/lua/my/plugins/lspconfig.lua +++ b/dotfiles/neovim/lua/my/plugins/lspconfig.lua @@ -4,41 +4,6 @@ local M = {} -- Command for formatting lua code local formatLua = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb" --- Use a loop to conveniently call 'setup' on multiple servers and --- map buffer local keybindings when the language server attaches -local servers = { - tsserver = {settings = {}, cmd = nil}, - sumneko_lua = { - settings = { - - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = runtime_path - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = {'vim'} - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true) - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = {enable = false} - } - }, - cmd = {"lua-language-server"} - }, - purescriptls = { - settings = {purescript = {censorWarnings = {"UnusedName", "ShadowedName", "UserDefinedWarning"}, formatter = "purs-tidy"}}, - cmd = nil - }, - rnix = {settings = {}, cmd = nil} -} - local function map(buf, mode, lhs, rhs, opts) local options = {noremap = true, silent = true} if opts then options = vim.tbl_extend('force', options, opts) end @@ -71,11 +36,53 @@ local function on_attach(client, bufnr) map(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()') end +local function on_attach_typescript(client, bufnr) + client.resolved_capabilities.document_formatting = false + client.resolved_capabilities.document_range_formatting = false + + on_attach(client, bufnr) +end + +-- General server config +local servers = { + tsserver = {on_attach = on_attach_typescript}, + sumneko_lua = { + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = runtime_path + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'} + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true) + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = {enable = false} + } + }, + cmd = {"lua-language-server"} + }, + purescriptls = {settings = {purescript = {censorWarnings = {"UnusedName", "ShadowedName", "UserDefinedWarning"}, formatter = "purs-tidy"}}}, + rnix = {} +} + function M.setup() -- Setup basic language servers for lsp, details in pairs(servers) do + if details.on_attach == nil then + -- Default setting for on_attach + details.on_attach = on_attach + end + require('lspconfig')[lsp].setup { - on_attach = on_attach, + on_attach = details.on_attach, settings = details.settings, -- Specific per-language settings flags = { debounce_text_changes = 150 -- This will be the default in neovim 0.7+ diff --git a/modules/applications/neovim.nix b/modules/applications/neovim.nix index e18bc87..3afbb72 100644 --- a/modules/applications/neovim.nix +++ b/modules/applications/neovim.nix @@ -25,7 +25,7 @@ in # Formatters luaformatter # lua - nodePackages.prettierd # prettier but faster + prettierd # prettier but faster # Others fzf # Required by lua-fzf @@ -42,6 +42,7 @@ in purescript-vim # purescript syntax highlighting nvim-comment # allows toggling line-comments nvim-treesitter # use treesitter for syntax highlighting + startup-nvim # splash screen ]; }; } diff --git a/modules/dev/javascript.nix b/modules/dev/javascript.nix index 2b766de..5305022 100644 --- a/modules/dev/javascript.nix +++ b/modules/dev/javascript.nix @@ -2,7 +2,8 @@ let node = pkgs.nodejs-17_x; yarn = pkgs.yarn.override { nodejs = node; }; -in { +in +{ home-manager.users.adrielus.home.packages = with pkgs; with nodePackages; [ node @@ -14,11 +15,11 @@ in { # TODO: find a good way to reinstall some of these /* tsdx - mklicense - preact-cli - create-next-app - create-snowpack-app - bower + mklicense + preact-cli + create-next-app + create-snowpack-app + bower */ ]; } diff --git a/modules/overlays/npm.nix b/modules/overlays/npm.nix index e7479ec..7b85275 100644 --- a/modules/overlays/npm.nix +++ b/modules/overlays/npm.nix @@ -1,6 +1,7 @@ self: super: -let customPackages = pkgs.callPackage ./npm { }; -in with self; { +let customPackages = self.callPackage ./npm { }; +in +with self; { # Faster prettier for editors - nodePackages.prettierd = customPackages."@fsouza/prettierd"; + prettierd = customPackages."@fsouza/prettierd"; }