Skip to content

Commit

Permalink
better nushell config (#1)
Browse files Browse the repository at this point in the history
* install Nushell's tree-sitter through TS itself

* remove `toolkit` commands, e.g. fetch queries
  • Loading branch information
amtoine authored Mar 9, 2024
1 parent 0ec7149 commit 7a3506c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 73 deletions.
3 changes: 2 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ require('lazy').setup({
'nvim-treesitter/nvim-treesitter',
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
'nushell/tree-sitter-nu',
},
build = ':TSUpdate',
},
Expand Down Expand Up @@ -442,7 +443,7 @@ vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc =
vim.defer_fn(function()
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' },
ensure_installed = { 'nu', 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' },

-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false,
Expand Down
10 changes: 0 additions & 10 deletions lua/custom/nushell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,3 @@ vim.filetype.add({
},
},
})

local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.nu = {
install_info = {
url = "https://github.com/nushell/tree-sitter-nu",
files = { "src/parser.c" },
branch = "main",
},
filetype = "nu",
}
62 changes: 0 additions & 62 deletions toolkit.nu
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
use std log

def install-queries [] {
if "VIMRUNTIME" not-in $env {
error make --unspanned {
msg: $"(ansi red_bold)VIMRUNTIME not set(ansi reset)
in order to install Neovim queries safely, please set the `$env.VIMRUNTIME` environment variable and run `toolkit install runtime`"
}
}

let local = $env.VIMRUNTIME | path dirname | path join "lazy" "nvim-treesitter" "queries" "nu"
let remote = "https://raw.githubusercontent.com/nushell/tree-sitter-nu/main/queries/nu"

let file = "highlights.scm"

mkdir $local

log info $"pulling query files from ($remote)"
http get ([$remote $file] | str join "/") | save --force ($local | path join $file)

log info $"queries successfully pulled down and stored in ($file)"
}

# create a symlink between the current directory and the config
export def setup [] {
install-queries
Expand All @@ -35,35 +14,6 @@ export def setup [] {
ln -s (pwd) $NVIM_CONFIG
}

def pretty-cmd [] {
let cmd = $in
$"(ansi -e {fg: default attr: di})($cmd)(ansi reset)"
}

export def import-git-projects [] {
let projects = $env.HOME | path join ".local/share/nvim/project_nvim/project_history"

mkdir ($projects | path dirname)
touch $projects

let before = $projects | open | lines | length

$projects
| open
| lines
| append (
ghq list | lines | each {|it|
print $"adding (ansi yellow)($it)(ansi reset) to the projects..."
ghq root | str trim | path join $it
}
)
| uniq
| save -f $projects

print $"all ('git' | pretty-cmd) projects (ansi green_bold)successfully added(ansi reset) to the ('projects.nvim' | pretty-cmd) list!"
print $"from ($before) to ($projects | open | lines | length) projects."
}

export def "install runtime" [
--runtime: string = "/usr/share/nvim/runtime/"
--user: string
Expand Down Expand Up @@ -103,15 +53,3 @@ export def "install runtime" [
log info $"copying custom Git syntax"
cp runtime/syntax/git.vim ($env.VIMRUNTIME | path join "syntax" "git.vim")
}

export def update [] {
install-queries
nvim -c ":TSInstall nu | TSUpdate"
}

export def upgrade [source: path] {
cd $source
git pull
make CMAKE_BUILD_TYPE=Release
sudo make install
}

0 comments on commit 7a3506c

Please sign in to comment.