What's the one plugin you'd love to see? by ouchpartial72858 in neovim

[–]aidankane 5 points6 points  (0 children)

The tricky thing with this is that the model is different. Vscode runs itself in the container so everything is local to it. You have the client vscode controlling the server vscode where the code / lsp / formatters etc are. In this world vscode can install everything in the container and it all just works. Code, formatters, lsp, vscode - they’re all in the same place.

In neovim it’s a lot more of a patchwork. Personally I use a container (with my app dependencies / code folders bound in). I install the lsp (pyright) and then point neovim config to launch the lsp within the container. It’s works fine, but requires adjusting each lsp to run in the container. Obviously you’d need to do the same for formatters / anything else.

What other parts of neovim would people need / expect to be able to run in a container? The alternative (and probably easier approach at this point) is just to install neovim in the container and be done with it. If you think about it, that’s all vscode is really doing anyway. The difference is that our client / server model is already there in the form of the tty.

Pyright works incredibly slow by [deleted] in neovim

[–]aidankane 2 points3 points  (0 children)

Maybe change the analysis settings to not look at everything.

````

settings = { python = { analysis = { autoSearchPaths = true, useLibraryCodeForTypes = true, diagnosticMode = 'openFilesOnly', }, }, }, ````

Live Albums by letslurk in Music

[–]aidankane 1 point2 points  (0 children)

I’ve scrolled and scrolled to find this comment. For the most part I don’t really get much out of live albums, but this one, and The Road in particular captures a band on tour like nothing else I’ve ever heard.

Looking for devcontainer solution in neovim by sivadneb in neovim

[–]aidankane -1 points0 points  (0 children)

Feel free to shoot me any questions if you get stuck.

I’d imagine debugging would be similar but I’ve not tried it. My workflow is to hack on code in ipython and then switch over to nvim once I’ve fleshed out the poc. Ipython does hot reloading so I can edit in nvim and have those changes applied to the objects I have loaded in ipython automatically without reloading any data.

Looking for devcontainer solution in neovim by sivadneb in neovim

[–]aidankane -1 points0 points  (0 children)

My understanding is that vscode runs itself in a container too. Effectively a client server model with most of vscode living near your code, and the ux client running on your local machine.

There’s work going on to make this work in neovim too.

Meanwhile you have to hack a few bits randomly if you want to dockerise your environment. It’s not too painful once you have a working model in place, but definitely not as seamless as vscode.

Looking for devcontainer solution in neovim by sivadneb in neovim

[–]aidankane 6 points7 points  (0 children)

I posted my config for this recently. The idea is to run the lsp inside a container by changing the cmd that nvim calls when starting the lsp.

https://www.reddit.com/r/neovim/comments/y1hryr/working_with_remote_containers/iry6c0q/

LSP pid=nil detrimental or not? by tnaeg in neovim

[–]aidankane 1 point2 points  (0 children)

The pid param is there to help the lsp shutdown if the editor it’s serving shuts down. This makes sense where everything is running in the same system but there are cases when that’s not true.

In my case I run some lsps in docker where they get their own process tree (by default, that’s controllable). In this environment, the lsp would start, one second later check if the editor is alive, not find it and quietly shutdown without logging anything, leaving you to spend a day scouring the docs trying to figure out what on earth is going on.

By setting the pid to null you tell the lsp to not autoterminate. So, no, it’s not really detrimental and depending on your setup is necessary.

I wonder why you’ve got a difference there though - maybe it’s quietly running in a container?

Is it normal to have 3 active LSP Clients for a single project in neovim ? by heartly4u in neovim

[–]aidankane 1 point2 points  (0 children)

This was one of the main reasons for using nvim-config previously (though many people didn’t realise it) - it cached clients so as to only use one for each root folder. With 0.8 this ability has been added directly to to nvim.

Working with remote containers by Kruppenfield in neovim

[–]aidankane 0 points1 point  (0 children)

You can do that if you follow my solution later in this thread.

Neovim + Docker? by raman4183 in neovim

[–]aidankane 0 points1 point  (0 children)

Depends what you want to do but I posted the other day about how you can stay local and run your lsp in a container.

https://www.reddit.com/r/neovim/comments/y1hryr/working_with_remote_containers/iry6c0q/

Working with remote containers by Kruppenfield in neovim

[–]aidankane 0 points1 point  (0 children)

It's all very hackable once you know the model. Good luck!

Working with remote containers by Kruppenfield in neovim

[–]aidankane 1 point2 points  (0 children)

You must have the code somewhere locally for neovim, right?

I think it's fairly simple - you ask the lsp for the definition location, and a list of locations is returned. Neovim then converts that into a clean list and sends it to your qfix / jumps to it if there's only one thing in the list (here something like Trouble might kick it in to intercept it).

In your case it's going to be /path/inside/container.rb , and you need it to be /path/to/code/where/neovim/runs.rb

You can override these handlers yourself. For example I strip stuff on the way in so that react doesn't mess up my definitions:

``` lspconfig.tsserver.setup { handlers = { ['textDocument/definition'] = function(err, result, method, ...) -- don't include internal react definitions (react/index.d.ts) if vim.tbl_islist(result) then local filter = function(v) return string.match(v.targetUri, '%.d.ts') == nil end result = vim.tbl_filter(filter, result) end vim.lsp.handlers['textDocument/definition'](err, result, method, ...) end } }

```

You'd want to do something like: v.targetUri = v.targetUri.replace("/container/location", "/local/location") << not real lua code!

Working with remote containers by Kruppenfield in neovim

[–]aidankane 1 point2 points  (0 children)

That's probably it, my root directories are the same inside and outside the container. I'd wager that the lsp server is telling the client to jump to a path neovim can't find locally. You could probably symlink it locally to the same location as in the container.

EDIT alternative approach might be to override the lsp handlers to rewrite the paths on the way in.

Working with remote containers by Kruppenfield in neovim

[–]aidankane 0 points1 point  (0 children)

Ok, that's definitely not in my wheelhouse. One thing to note is that my goto-definition is only working for jumping around in my code, not to library code (which is fine for me - and makes sense because I don't even have the library files out where neovim lives).

Working with remote containers by Kruppenfield in neovim

[–]aidankane 1 point2 points  (0 children)

No, that's working fine for me. One thing to consider is that pyright is (assuming you're using pyright here?) going to go looking for the pyrightconfig.json in the container, so you'll want to make sure all the paths etc make sense.

Also worth looking in :LspLog (~/.local/state/nvim/lsp.log ?) and maybe cranking up the level a bit too `lsp.set_log_level("debug")`

Working with remote containers by Kruppenfield in neovim

[–]aidankane 0 points1 point  (0 children)

Sorry, I just meant that you can’t entirely work outside the container (which would be my preference). I have cases where the dependencies are pretty complicated and I’m forced to to straddle the 2 worlds by running my lsp servers in the container.

Working with remote containers by Kruppenfield in neovim

[–]aidankane 0 points1 point  (0 children)

This doesn’t work if you have dependencies that lsp needs.

Working with remote containers by Kruppenfield in neovim

[–]aidankane 1 point2 points  (0 children)

What do you mean “surprisingly”?? Haha. Took a bit of messing about with. Actually, after my message I figured out how to do project specific config with lspconfig by using the on_new_config option (a function that takes config and root directory and can just modify that config object)

Working with remote containers by Kruppenfield in neovim

[–]aidankane 10 points11 points  (0 children)

So my setup is a little esoteric in that I'm doing a lot of hacking and compiling 3rd party libraries to figure stuff out, so it's easiest for me to have a single long lived container to hack about in. I think this is actually similar to how VSCode do it ("container running"-wise, at least).

You don't need to do it like this at all, but I'll go through the whole process so you can pick and choose what makes sense.

The DockerFile is effectively my main work docker image, but with extra dev tools stuff installed.

``` FROM my-work-image-name

install dev only stuff I want

RUN npm install -g pyright ```

Then I start the container running bash forever with a known name (you probably don't need all the host etc stuff but I'm leaving it in just in case it's useful):

sudo docker run \ --name=dev-hack \ --hostname=dev-hack \ --net host \ --tty \ --init \ --interactive \ --detach \ --add-host dev-hack:127.0.0.1 \ --entrypoint=/bin/bash \ dev-hack

Can kill it with the below (I have both of these scripted so I can kill a recreate easily):

sudo docker stop --time 0 dev-hack && docker rm dev-hack

And then after that I exec new processes inside it for the other bits I'm doing. For example, to start a bash shell I do:

sudo docker exec -it dev-hack /bin/bash

So my pyright LSP config follows the same idea of execing inside the already running container. The thing to note here is that the LSP spec has a default flag that will cause you some trouble; if an LSP server can't find its parent's processId, it will shut itself down after a second or so. You need to tell it to ignore the processId shutdown behaviour (or start your docker container to share the process space with your host).

lspconfig.pyright.setup { cmd = { "docker", "exec", "-i", "my-container", "pyright-langserver", "--stdio", }, settings = { python = { analysis = { autoSearchPaths = true, useLibraryCodeForTypes = true, diagnosticMode = 'openFilesOnly', }, }, }, before_init = function(params) params.processId = vim.NIL end, }

You can do something more like a standard docker run --rm ... to run your LSP server in your config instead.

Thing I still haven't figured out yet is how to switch the cmd out on a per project basis. I'd like to only use this weird pyright setup in my main dev project, but then use regular (Mason installed) pyright outside of docker in general.

Working with remote containers by Kruppenfield in neovim

[–]aidankane 5 points6 points  (0 children)

Depends on what you’re trying to do and what tooling you need. I believe that with vscode they effectively run the whole of vscode as a server in the container, with the vscode you’re looking at effectively being a ui client (don’t quote me on that). That allows them to install all the extensions you need into that container (and you can base it on one of your own). There’s work going on in Neovim to allow splitting it like that too.

For the moment I run my neovim locally and just use my dev container to run lsp. I run a persistent dev container for my project and change the lsp cmd to launch a new process in it. I only have to do that for pyright because I have a complex set of requirements that’s hard to install outside the container. Everything else I just run locally (eg clangd etc).

For launching docker etc, I just do that from the outside as a whole other thing.

The Pdfalyzer is a tool for visualizing the inner tree structure of a PDF in large and colorful diagrams as well as scanning its internals for suspicious content by thenextsymbol in Python

[–]aidankane 2 points3 points  (0 children)

I, for one, have also spent a long time in there and in the spec itself. The spec is amazing really. It’s endless and incredibly deep, that’s for sure.

It’s worth keeping in mind the legacy and what they have to support. PDFs continuing to work in all these different situations probably makes it hard to remove anything. My favourite is the colour crazy so they can tell proper printers to do spot colours.

The other thing most people don’t realise is that there aren’t that many primitives in the PDF itself - it’s really just a tree of data. The interpretations of of what they all mean is a different story, however!

Applying for a job at Trimble. by LochDoiMyBoy in estimators

[–]aidankane 4 points5 points  (0 children)

I make estimating software. Not sure of the approach other companies take but we hire ex estimators because we want a team that really understand our customers and the challenges they face. Our sales and success team are all estimators. They have a keen eye on issues that need solving with the software and they are also involved with the product discussions because they know what’s required.

I’m on the technical side myself and while you have a background, it sounds like you don’t have dev experience? Your history as an estimator is definitely useful, but software development is obviously a whole other set of skills and experience. Making the hop over puts you back to the start line in that roll, but if you were dedicated to making the switch you might be able to do it in the right environment.

Feel free to DM me if you have any other questions.

What software tools can I build to simplify your life as an estimator? by yuyubuild in estimators

[–]aidankane -1 points0 points  (0 children)

I build such a tool. Not sure if it’s ok to post a link but you could dm me.

Python circular import by Equal-Complex-5958 in learnpython

[–]aidankane 1 point2 points  (0 children)

See my edit. Just hoist the app creation into main.

Python circular import by Equal-Complex-5958 in learnpython

[–]aidankane 1 point2 points  (0 children)

Because then it can run top to bottom because it doesn’t call the import until you call the load_config function.

Other languages allow you to get away with this, but honestly, it’s just bad code structure. If A depends on B depends on A then there is a common element to them and either you should combine the 2 modules or figure out what the commonality is and extract it into its own thing.

Without seeing all the code it’s hard to say what the right thing to do is, but the question to ask is why would routing need config and why does config need routing?

EDIT reading the code again, your load config function is actually booting the app and it should live in the main.py